Results 1 to 10 of 10
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading A CSV File (XP:SP3)

    I can not find a response to a similar question I had about reading files. In this case it is a CSV file, which is suppose to be comma delimited. Unfortuantely when I try to read the first line I encounter memory issues (out of memory). It is as if the entire file is one line.

    Open FileToOpen For Input As #1
    Do While Not EOF(1)
    Line Input #1, LineofText

    Thanks,
    John

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    It is not possible for us to tell without seeing the .csv file. If it does not contain any confidential information, can you compress it into a .zip file that is less than 100kb and attach it to a reply?
    Legare Coleman

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Reading A CSV File (XP:SP3)

    What happens if you use File|Open, with the type set to "Text files (*.prn; *.txt; *.csv)"?

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    Star Lounger
    Join Date
    Mar 2001
    Location
    Ontario, Canada
    Posts
    57
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    Could also be a problem with the system that the csv file is created on. PC/UNIX/MAC all use different end-of-record markers (e.g. PC uses CRLF) and I've run into problems trying to open a file created in unix into Excel. If this could be the problem, then there should be a way of modifying the file to use the correct marker (e.g. on unix run it through unix2dos).

  5. #5
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Reading A CSV File (XP:SP3)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> John

    Just as Macropd said, what happens if you simply open the file?

    I thought CSV was one of the file formats that Excel can and should be able to read without the code.

    You may want to check these selectedMSKB articles, just in case we are full of it: <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    How to bypass the Text Import Wizard when you import files in Excel
    How to parse data using the Text To Columns command in Excel
    How to export data to a text file with comma and quote delimiter in Excel
    Importing text files larger than 65536 rows

    These are more articles can be found by searching the MS-Excel product line using the keyword <font color=red>Text</font color=red>

    Hope these help.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Reading A CSV File (XP:SP3)

    After encountering problems of this sort, I would be looking at this with a text editor.
    Regards
    Don

  7. #7
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Birmingham, West Midlands, United Kingdom
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    Further to Wassim's helpful references, curious that this one
    "How to export data to a text file with comma and quote delimiter in Excel"
    is devoid of any sample code!
    It merely says it's possible.
    One of the other refs has nicely-commented specimen code.

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    Jhon, i have a good experince with txt file...
    If you attach a little part of your file peraphs i can help you.
    Attach only a little part...

  9. #9
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    In reference to my original <!post=post,510182>post<!/post> I finally managed to locate a <!post=response,359107 >response<!/post> from Steve (adckapr).

    I encountered this same issue way back in 2004 but was unable to successfully search for the post. I went out of town for a week and then came back and found the reply.

    Many thanks to those who replied,
    John

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading A CSV File (XP:SP3)

    Ok...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •