Board index » cppbuilder » Parsing a CSV file...
Lee Gobroski
![]() CBuilder Developer |
Lee Gobroski
![]() CBuilder Developer |
Parsing a CSV file...2005-03-24 07:58:23 PM cppbuilder26 Hello all, I have been spending the last couple of days trying to find a way I can load a CSV file, and then parse it. what I would like top do ideally is load the first record of the file in to the form, and then click on next and then have it show the next record. I was wondering if that could be done with out leaving the file open, of having to reopen it, or look at the file. thanks in advance for your help. Lee |
Analian
![]() CBuilder Developer |
2005-03-24 08:17:27 PM
Re:Parsing a CSV file...
Recently I was messing aroung with CSV files and wrote import / export
routines for such formats so I think I might help you but didn't quite get what are you trying to accomplish. As far as I understood you want to open the file once, close it and then not use it any more. In that case you have to read the file's content in an array in your program and use it later. Or you mean something else? |
Hans Galema
![]() CBuilder Developer |
2005-03-24 09:32:23 PM
Re:Parsing a CSV file...
Lee Gobroski wrote:
QuoteI have been spending the last couple of days trying to find a way I can load StringList->LoadFromFile ( your filename ); I suppose that every record is on a line. int nrecs = StringList1->Count; To get the line for a record with a certain recnr < nrecs: AnsiString Line = StringList->Strings[recnr]; Now you have to parse only this line but TStringList can do for you that. Is the ',' the separator ? Put the line in a different TStringList with: StringList2->CommaText = Line; Now StringList2->Strings[] contain the values. Hans. {smallsort} |
maeder
![]() CBuilder Developer |
2005-03-25 01:33:54 AM
Re:Parsing a CSV file...
"Lee Gobroski" < XXXX@XXXXX.COM >writes:
QuoteI have been spending the last couple of days trying to find a way I can load it while you are parsing it. |
Lee Gobroski
![]() CBuilder Developer |
2005-03-25 02:29:23 AM
Re:Parsing a CSV file...
Hello,
Thanks for you help thus far. here is a sample of what I am reading in: Last,First,Middle,Suffix,City Abel,Evan,F,III,Spokane Aberle,Nicholas,Richard,,Yakima I kind of guessed that I would have to add the file to an array, but I am sure just exactly how to do that in C++ Builder 6.0. The current file is only 55 K so I don't have to worry about the 20 meg limit of the TStringList. again thanks for your help thus far Lee "Lee Gobroski" < XXXX@XXXXX.COM >wrote in message QuoteHello all, |
Hans Galema
![]() CBuilder Developer |
2005-03-25 02:36:34 AM
Re:Parsing a CSV file...
Lee Gobroski wrote:
Quoteso I don't have to worry about the 20 meg limit of the beeing that operations would take longer and longer with increasing size. Hans. |
Lee Gobroski
![]() CBuilder Developer |
2005-03-25 04:07:54 AM
Re:Parsing a CSV file...
OK, thanks.
How do I get the file contents to the Tstinglist? Thanks Lee "Hans Galema" < XXXX@XXXXX.COM >wrote in message QuoteLee Gobroski wrote: |
Hans Galema
![]() CBuilder Developer |
2005-03-25 04:14:29 AM
Re:Parsing a CSV file...
Lee Gobroski wrote:
QuoteHow do I get the file contents to the Tstinglist? |
Liz Albin
![]() CBuilder Developer |
2005-03-25 05:13:04 AM
Re:Parsing a CSV file...
On Thu, 24 Mar 2005 12:07:54 -0800, Lee Gobroski wrote:
QuoteHow do I get the file contents to the Tstinglist? -- Good luck, liz |
Lee Gobroski
![]() CBuilder Developer |
2005-03-25 12:02:39 PM
Re:Parsing a CSV file...
Hans,
Thanks. I missed that. Lee "Hans Galema" < XXXX@XXXXX.COM >wrote in message QuoteLee Gobroski wrote: |