473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

read a csv file for only data you want

I'm having a problem getting just the data from the file I want. I can get the file to read in to a msflexgrid but I can't get the data out of the cells I want is there an easier way to read a csv for data?

Thanks in advance.
Oct 6 '07 #1
5 1329
Killer42
8,435 Expert 8TB
Sure. You can just open and read it as a text file. Either by using the built-in Open and Line Input # statements, or by using the FileSystemObject model. There are samples in the VB Articles area that show how to do this.

Extracting the particular data that you want may be very simple, or slightly more complex, depending on the answer to one important question...
Is it possible that any of the data fields can contain a comma?
If not, then you can just use the Split() function to split up the record into and array based on the commas. However, if there may also be commas in the data, that won't work and you will have to do a bit more work.
Oct 7 '07 #2
Sure. You can just open and read it as a text file. Either by using the built-in Open and Line Input # statements, or by using the FileSystemObject model. There are samples in the VB Articles area that show how to do this.

Extracting the particular data that you want may be very simple, or slightly more complex, depending on the answer to one important question...
Is it possible that any of the data fields can contain a comma?
If not, then you can just use the Split() function to split up the record into and array based on the commas. However, if there may also be commas in the data, that won't work and you will have to do a bit more work.

this is a line from the file i need to read.

2007-May-22 07:29:55 AM,,VIN:00000000000000000 CSN:0000000 BCM_PN:00000000 IPC_PN:00000000 RADIO_PN:00000000 HVAC_PN:00000000 HUD_PN:******** XXXXX-967 2008 AUTO_HVAC FOG_LAMP_SW GPS_PRESENT TELESCOPING_STEER DIC_PRESENT REAR_DVD, FAILED ,PASS,PASS,*NOT DONE*,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS ,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS ,PASS,*NOT DONE*,PASS,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,PASS,*FAIL*,PASS,PASS,PASS,PASS,PASS,PA SS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PASS,PA SS,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,*NOT DONE*,PASS,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,PASS,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,PASS,PASS,PASS,PASS,PASS,*NOT DONE*,PASS,*NOT DONE*,PASS,PASS,PASS,*NOT DONE*,*NOT DONE*,PASS,PASSED,PASSED,PASSED,PASSED,PASSED,PASS ED,PASSED,PASSED,PASSED,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PA SSED,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PAS SED,PASSED,PASSED,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PA SSED,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PAS SED,PASSED,PASSED,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PA SSED,PASSED,PASSED,PASSED,PASSED,PASSED,PASSED,PAS SED,PASSED,PASSED,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PASSED

the bold underlined fields is all i really need from the file.
Oct 7 '07 #3
Killer42
8,435 Expert 8TB
...the bold underlined fields is all i really need from the file.
Well, as I said, as long as none of the fields up to that point can contain a comma, it's simple. Just use the Split() function to separate the fields into an array. Then use items 0, 2 and 3 from the array. Looks as though you will need to chop up item 2 a bit, as well. This is where things like the Mid() and Instr() functions will come in handy.
Oct 8 '07 #4
Well, as I said, as long as none of the fields up to that point can contain a comma, it's simple. Just use the Split() function to separate the fields into an array. Then use items 0, 2 and 3 from the array. Looks as though you will need to chop up item 2 a bit, as well. This is where things like the Mid() and Instr() functions will come in handy.
I'm trying to get that to work now.

Thank you for the help.
Oct 8 '07 #5
Killer42
8,435 Expert 8TB
I'm trying to get that to work now.

Thank you for the help.
No problem.

Let us know how it goes. :)
Oct 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
7
by: TechBoy | last post by:
RE: Access 2002 SP3 I have an app "App1.mdb" that has internal security built-in via a table: tblSecurity. In this table a match is obtained to see if they are authorized to use the app. This...
3
by: Sobhan | last post by:
Hi all, I am writing a program in C in which I need to read a data file and export to the excel.The Data in the file in CSV format. Values in the .txt file are as follows: "a","b","c" 10,20,30...
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
19
by: ranjeet | last post by:
Hay Guys can you all suggest me the points on the below issue Problem : The thing is that I have the data some thing like this. 1486, 2168, 3751, 9074, 12134, 13944, 17983, 19173, 21190,...
18
by: JG | last post by:
Does anyone know a standard (or supported on Linux, Mac, Win32) way to clear a read stream buffer (standard ANSI C file stream)? I would even settle for a platform specific way of doing it. ...
8
by: james | last post by:
I am trying to use Filestream to read a file ( .DAT) that contains values in HEX that I want to convert to text. I know the different offset addresses for each portion of the data I am trying to...
34
by: Ross Reyes | last post by:
HI - Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did not find a satisfactory answer. When I use readlines, what...
3
by: phwashington | last post by:
I am new to C++ and have a data file I want to read, which was stored in binary. I have looked at the data with a hex editor and it appears to be correct. Whenever I try to read it though as an...
4
by: greg | last post by:
Hi, I have a read only access file with a linked table that connects to a sybase database. So I can still add data to the table even though its read only since the table is really in sybase. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.