Open Csv With Wordpad

  • Hallo,



    I would like to Use my Excel VBA program to do this:


    User Selectable: Open a CSV file using wordpad.


    Once the program is opened I would like to search each row in the document for a name (value of 5 as a unique identifier) if the name exists then I would like to delete the entire row.


    After the whole document is done I would like to close it and save changes.


    The reason that I cant do this using excel is because the file gets screwed up, whenever I try to do the above in excel, even when I save in csv format and everything. The file has to be procesed through a nother program once I delete the unvanted info that is very picky about commas and any alteration in excel results in the file being incorrectly used.


    The only method that I found that works is when I MANUALY open the csv in wordpad delete the lines I dont want and then close and save changes. Using this method the other program acepts the chaged file without a problem.


    I would really appreciate some help with this as I have been battling with this issue for months. Only now I finaly found the manual solution and I still cant write this sort of thing by myself.


    I can write the code to use excel to do it and it seams preaty simple. If what I need requires too complex an answer then please dont worry as I probably wouldnt understand it anyway.


    I have included the code that does what I want in excel but results in the csv file being unusable.



    I hope that I have obayed all the required bylaws of this forum. I reaklise that this question is 3 fold but each is tied into each other
    Imnot sure that spliting them into each section would have been a workable solution. Please let me know if I posted incorectly.


    Michal

  • Re: Open,edit,close Csv With Wordpad


    Quote

    Open a CSV file using wordpad.

    Impossible.



    Code from Jindon;

  • Re: Open Csv With Wordpad


    Hi,


    I have this code that does open the CSV in wordpad now. Took 5 hours of searching but I suppose the imposible just takes a litle bit of extra time especialy for newbies like me.


    I wonder if anyone can help with reading the lines and finding the unwanted info and deleting the line from the document .





    Michal

  • Re: Open Csv With Wordpad


    Mike


    I've got to agree with Dave here.


    There is no such thing as a Wordpad file, it's a text file that you could open in any number of applications eg Wordpad, Notepad etc

    Boo!:yikes:

  • Re: Open Csv With Wordpad


    Hi,


    I have no idea how the notion that Im thinking that a CSV is a wordpad file came about.


    I wanted to know how to :


    Using VBA code in my excel sheet I want to open a CSV file using Wordpad, and then to edit and close that file.


    Dave answered that Open CSV file using wordpad is imposible.


    Now that is not true is it because I have a code that does that. I may be on the wrong track with this in regards to what I want to do with it next. If you feel that I have attacked him for some reason then let me saythat I am pointing out the facts as I see them. Perhaps you both with your experiance realise that what I want to do is infact imposible the way that Im attempting it. But Im only doing the best that I can.


    But thank you for your time anyway,


    Michal

  • Re: Open Csv With Wordpad


    Hi Jindon,


    I have explained this in my initial post. For some reason it does not work. I have tried saving it in both the formats of CSV that are available in the save as file types.


    Basicaly the file is one that is used by a nother program to analyse the data in it. It must be CSv because that is the file that it looks for.


    I am basicaly "breaking in" into the file before the program runs it to delete certain lines to suit what I want to analyse. I have tried all possibility in excel but non work as they alter the file from what is expected by the analyser program because the data then comes out distorted and incorectly presented.


    When I do this manualy in word pad then the file retains the formating that it needs and is procesed by the analyser program without any glitches. Im not sure why but that is the facts.


    I may be abel to do this in word but wordpad retains the lines where as word wraps them making it dificult to know wher the line finishes.


    Thank you,


    Michal

  • Re: Open Csv With Wordpad


    CSV is just a comma deloimited Text file, therefore it should not differ from the software that you use.


    If you really need to open it via WordPad, it will much be complex.
    vba code will not easy as you think from the mannual edit.
    However excel will be much easier...


    But, sorry no idea about your situation.

  • Re: Open Csv With Wordpad


    Quote

    Dave answered that Open CSV file using wordpad is imposible.

    I think you are confusing "with" with "within" and as Norie has stated, there is no such thing as a Wordpad file it is a Text file, BUT only when saved.


    Mike, your Thread is a classic example of a user not knowing how to do something, yet insists on going down a one-way Street simply because they THINK they know their means to an end.


    When you posted your question, you were told in BIG BOLD FONT to NOT assume your answer in Thread Titles and ONLY use them to title what you are wanting to do.

  • Re: Open Csv With Wordpad


    Hi JinDon,


    I agree with your assumption it shouldnt matter what software I use but the unfortunate fact remains that for some silly reason it does.


    Dave I realise that I am stearing the answer to what I want but in my defence Im after a solution to how to do what I want not how others might solve my situation. As you can see their solutions while logical do not work because of the silly reason I outlined. So I only want the answers to my question relating to opening and editing a CSV file using wordpad not a solution to my problem. Unless someone can point out where the error is in my excel code in which case you will be entirely correct. I didnt think that that would happen so I have to ask for the solution in a way that I can integrate it into my program and that will work within the limitations.


    However I again take your post onboard


    Thank you


    Michal

  • Re: Open Csv With Wordpad


    Hello Michal


    Excel will only 'alter' csv files if the csv file is actually opened up by Excel - what Jindon/others are meaning is that to process the file as you intend, you do not need to open the file in Excel (for example, VBA could simply do the processing in memory). Thus it is possible to use Excel to do this and this is why Dave is making the point that you shouldn't assume the answer (and this consideration is applied to everyone, even experts posting questions) - as frequently there will be some way that the poster hasn't considered to achieve a solution.


    What are the conditions in the file you want to check for and remove/modify?


    Richard

  • Re: Open Csv With Wordpad


    Quote

    So I only want the answers to my question relating to opening and editing a CSV file using wordpad not a solution to my problem

    That is one of the weirdest statements I have heard in a while!


    It is like buying car that SHOULD get 10KM per litre but it runs out at 9KM and you refuse to put anymore petrol in.


    Had you clearly stated what you are wanting to do 1st up, along with a matching Thread Title, I'd bet you would had your solution within minutes.


    Anyway, if you do wish to solve your problem, please start another Thread with a Thread Title that states what you want to do. Please, DO NOT go into using Excel in this Thread!

  • Re: Open Csv With Wordpad


    Hi Richard,


    Thank you for taking interest, yes I can see what you mean and also what Dave is pointing at.


    I want to examine cell "AJ" on every row and delete that row if the value is 5 (number).


    Dave PLEASE I am at a loss as to what I need here, may be you can suggest a title that you'll be happy with and I can place the resolved solution in there?


    Michal

  • Re: Open Csv With Wordpad


    Quote

    I want to examine cell "AJ" on every row and delete that row if the value is 5 (number).

    Based on that only, use one like: Delete Rows Meeting Criteria in 1 Column


    Quote

    Dave PLEASE I am at a loss as to what I need here

    You don't need to know what to do, you only need to know what you are wanting to do.

  • Re: Open Csv With Wordpad


    Michal,


    This may not be what you are looking for but if your CSV cannot be edited in Excel, have you tried editing it in MS Word instead?


    Regards,
    X10A

  • Re: Open Csv With Wordpad


    Hi X10A,


    I have edited the file manually in wordpad and the result is good. The file retains the formating. It may be possible that word can do the same I however have not got the programing skills to acomplish this by myself.


    Michal

  • Re: Open Csv With Wordpad


    Have you looked at your locale settings and what character is specified as a delimiter (list separator - Control Panel --> Regional and Language Settings --> Regional Options Tab --> Customize)? Excel uses this when crating CSV files and if the character is different from the delimiter required by your other software this might be the issue.


    I used to have a situation here I would retrieve CSV data from proprietary software modify it in Excel and then load it back into this software. The macro I designed worked fine on my pc with UK locale specified, but somebody else using Greek locale could not get macro to work properly. It turned out that Greeks use ';' as a default delimiter rather than ',' but the proprietary software only understood ','. Tweaking the local settings solved the issue.

  • Re: Open Csv With Wordpad


    Hi Michal,


    Maybe you can try this.


    1) Manually import the CSV file from Excel.
    2) Then apply AutoFilter and filter out all records in column AJ that is <> 5
    3) Copy the filtered range and paste to another workbook.
    4) Save the new file as CSV type.


    See if this works.


    Regards,
    X10A

  • Re: Open Csv With Wordpad


    Adjust for yourself

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!