473,803 Members | 4,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read a csv file for only data you want

3 New Member
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 1383
Killer42
8,435 Recognized Expert Expert
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 FileSystemObjec t 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
lazyman
3 New Member
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 FileSystemObjec t 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:000000000 00000000 CSN:0000000 BCM_PN:00000000 IPC_PN:00000000 RADIO_PN:000000 00 HVAC_PN:0000000 0 HUD_PN:******** XXXXX-967 2008 AUTO_HVAC FOG_LAMP_SW GPS_PRESENT TELESCOPING_STE ER 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,PA SS,PASS,PASS,PA SS,PASS,PASS,PA SS,PASS,PASS,PA SS,PASS,PASS,PA SS,PASS,PASS,PA SS,PASS,PASS,PA SS,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,PASS ED,PASSED,PASSE D,PASSED,PASSED ,PASSED,PASSED, PASSED,PASSED,* NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PA SSED,PASSED,PAS SED,PASSED,PASS ED,PASSED,PASSE D,PASSED,PASSED ,PASSED,PASSED, PASSED,PASSED,P ASSED,PASSED,*N OT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PA SSED,PASSED,PAS SED,PASSED,PASS ED,PASSED,PASSE D,PASSED,PASSED ,PASSED,PASSED, PASSED,PASSED,P ASSED,PASSED,*N OT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,*NOT DONE*,PASSED,PA SSED,PASSED,PAS SED,PASSED,PASS ED,PASSED,PASSE D,PASSED,PASSED ,PASSED,PASSED, PASSED,PASSED,P ASSED,PASSED,*N OT 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,PA SSED

the bold underlined fields is all i really need from the file.
Oct 7 '07 #3
Killer42
8,435 Recognized Expert Expert
...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
lazyman
3 New Member
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 Recognized Expert Expert
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
40285
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 user commits. But in Informix there is this thing called ISOLATION LEVELS. For example by setting the ISOLATION LEVEL to DIRTY READ, a user will read dirty data, i.e. the last uncommited updated value of a field by some other user. Is
7
2475
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 application has no Jet security being used ("Users/Groups", etc.) One of the requirements was to hide the DBWindow completely from the users, which works fine and the DBwindow is secure from all users. Another requirement for App1.mdb: the users...
3
7611
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 40,50,60 70,80,90 For that I need to read the values column wise.
1
4312
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 time after routine process A, the text file is named "mytext.dat" in following format with "#####" as separator. The maximum entries of them is 5. When reaching the fifth entry, it will delete the very first entry.
19
2525
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, 21820, 1730, 2640, 3450, 4870, 6126, 7876, 15644, 17817, 20294, 21902, 2070, 3025, 4333, 5854, 7805, 9231, 10597, 16047........................... soo onnnnnn
18
5706
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. And no, I know I can use direct low level I/O or non-buffered to do reads, but for my app, I need the buffering. I can implement myself, but this is not optimal. Example, I open a read only file using fopen(). I periodically know
8
7263
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 retrieve. But, I am having problems actually reading the data for the number of Bytes that I need to get from each address. Here is some of the code I am currently working with: Dim fsread As FileStream = File.Open(OpenFileDialog1.FileName,...
34
2818
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 happens if the number of lines is huge? I have a very big file (4GB) I want to read in, but I'm sure there must be some limitation to readlines and I'd like to know how it is handled by python. I am using it like this:
3
3241
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 integer it returns the 8bit integer values. I can convert these to hex and they match up with what I am seeing in the data file. I guess what I need to do somehow buffer these inputs and then read them as floats, but I am not sure how to do...
4
5518
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. However, I want to import data from an excel file (either via a macro in excel or access) but I always get an "Error 3051" because the access file is read only. Does anyone know a good workaround to this? I've been using the TransferSpreadsheet...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10309
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.