Parsing CSV

Hi,
im using A file with records in my mfc application, i need to read*/write 
records to the file anybody ahs a clue where should i start? 


0
fkpkot (25)
11/12/2005 10:42:54 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1157 Views

Similar Articles

[PageSpeed] 32

Take a look at CStdiofile and CString::Format() (for output) and 
CString::Tokenize() (for parsing input).  You can use ReadString() and 
WriteString() to access the file line by line.

Tom

"fima" <fkpkot@gmail.com> wrote in message 
news:eXA9vp95FHA.1184@TK2MSFTNGP12.phx.gbl...
> Hi,
> im using A file with records in my mfc application, i need to read*/write 
> records to the file anybody ahs a clue where should i start?
> 


0
tserface (3860)
11/12/2005 11:26:29 PM
"fima" <fkpkot@gmail.com> schrieb im Newsbeitrag 
news:eXA9vp95FHA.1184@TK2MSFTNGP12.phx.gbl...
> Hi,
> im using A file with records in my mfc application, i need to read*/write 
> records to the file anybody ahs a clue where should i start?

There are several groups of functions to read and modify the contents of 
files:

- Unix-like functions: open/creat/read/write/close
- Standard C functions: fopen/fread/fwrite/fprint/fclose
- C++ streams: fstream/ifstream/ofstream
- Windows API: CreateFile/ReadFile/WriteFile/CloseHandle
- MFC: CFile

Read the docs to learn how to use those functions.

HTH
    Heinz 


0
hozwirk.SPAM (112)
11/12/2005 11:35:45 PM
Try this:

http://www.codeproject.com/string/splitstring.asp?df=100&forumid=2089&exp=0&select=563545


----
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
11/12/2005 11:42:33 PM
Reply:

Similar Artilces:

csv values
Hi, I'm experiencing a weird behaveour by excel: when i double-click a csv file it opens excel (as it should) but, instead of appearing the import text dialog box, or importing directly into a new excel sheet, it opens all the file in just one column (with each row correctly defined, but with just one column which have allthe information eith commas like ",,,,Country,,,,,", etc.). The only way to make it import the file is to go to data>import>.... (which is quite borring and time consuming when we are opening several files, which is the case) I believe I'v alre...

Using CSV and quotes
Hi there. I have some applications that accept data as a CSV file (where ALL fields must be quoted). In Excel when I save as CSV it does not put quotes around text fields that do not contain spaces etc. Is there anyway to make Excel automatically quote all text fields? Thanks Neil You have to use a macro. Here's one: ''Outputs the selection if more than one cell is selected, else entire sheet Sub OutputActiveSheetQuotesAroundAll() Dim SrcRg As Range Dim CurrRow As Range Dim CurrCell As Range Dim CurrTextStr As String Dim ListSep As String Dim FNa...

excel changes a string in a csv file to a date format! how to get around this?
hi experts... i have a csv file with a one field as follows: ........ ,"2300-1-6", ............... this is not a date. it is a string that i want to appear just like that. but in excel, it imports it as a date and changes it to 1/6/2300 i tried to change the cell format from date to general (or text), but this makes it appear as 146104. i tired to rename the .csv file to .txt and play with the import options, but nothing worked. can someone please help! thanks hilz Never mind. i found it. When the file is changed to txt file, the import options can handle it. i just did not know...

How do I parse the data in a cell
I have an excel workseet with the following type of data: white-jungle.XL white-jungle.XXL jungle-smoke.S berny blue-smoke.S berny blue-smoke.M I need to parse the 'sizes'(everything after the period) and put it another column. Any help would be appreciated. You could use Data|Text to columns Delimited by a . If there are no other dots in the cell. Randy wrote: > > I have an excel workseet with the following type of data: > white-jungle.XL > white-jungle.XXL > jungle-smoke.S > berny blue-smoke.S > berny blue...

Can I schedule a recurring import of a csv file for contacts
Hi i would like to be able schedule the import of a csv file into Outlook contacts, so that the import happens automatically every month. Is this possible? Many thanks in advance. A There is nothing in Outlook that will allow you to do that - you would have to write your own code. ContactGenie DataPort 3.0 may be something of interest which does enable that capbility and also allows updating of pre-existing contacts based on the assignment of "one or more" user-selected "key fields" using any standard or custom Outlook fields - (ergo - not restricte...

Extra prompts from Excel 2007 after saving a CSV file
Here's the scenario: 1. I open a .CSV file in Excel 2007. 2. I make some data change to the file. 3. I save the file. Excel prompts me to use the CSV format again. This is a little annoying, but I answer Yes, I want to keep this format. 4. I try to close Excel. 5. Excel prompts me with "Do you want to save the changes you made to '(filename)?' Yes/No/Cancel. This is INFURIATING. I just saved the darn file. So I click No, thereby training myself to click no when prompted by Excel to save changes, guaranteeing I'll lose work in the future. Does anyone know a way to get E...

Opening CSV, How to Tell Excel String is not a Date?
In a CSV file I have values like "3-1". Excel interprets this as a date: 3/1/05. What encoding can I use in my CSV files to force Excel to read it as a literal string? I have already tried double quotes around the string. I am using Excel 2003. (Maybe) you probably had the cells formatted as a date when you imported the file. Or When you import treat dates as text. See the options in the Import wizard and try different scenarios. "Tim G" wrote: > In a CSV file I have values like "3-1". Excel interprets this as a date: > 3/1/05. What encoding can...

Display of Double byte chars in CSV files
Hi, I am trying to export some double-byte characters to CSV and trying to open the CSV file, but the double-byte characters are now being changed to some junk characters. My client doesnt want to do any other operations on the exported CSV file, like opening the file and saving that again in Unicode and then open it to get the double-byte characters display properly. Is there any solution that I can get? Thanks Raghuveer. ...

Export file to CSV delimited with fixed field length
Hi there! I have an Excel file with a series of fields, each in one column. What I need to do is determine a fixed length for each of these fields, so that when I export this file to a CSV file, I get a file in which each column has exactly the same fixed length. For example, if my Excel file contains: A B C 1234 ABC21 1234 and I want fields to have these fixed lengths: A - 5 B - 6 C - 4 my CSV file should contain: 1234 ;ABC21 ;1234 Any easy way of accomplishing this? I tried custom cells but when exporting, I lose the information. Thanks in advance. One way: http://www.mcgimp...

Error
Any help appreciated I suspect this has something to do with either permissions and/or excel setting but ... HTML (or CSV) file is saved to network share Attempt to open this file using Excel ( 2000 or XP ) and get information (i) error message "The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding." If file is saved to local drive, there is no problem opening this file from within Excel How can we open this file direct from Excel? ...

Need help : Open a csv file with semicolon separation
Hello everybody, I need to open a csv file with semicolon separation but the separation used is always the comma. I tried this differents methods : - Workbooks.OpenText Filename:="D:\Excel\data\file.csv", Semicolon:=True, Comma:=False - Workbooks.open Filename:="D:\Excel\data\file.csv", Format:=4 - Workbooks.open Filename:="D:\Excel\data\file.csv", Delimiter:=";" - Workbooks.open Filename:="D:\Excel\data\file.csv", Delimiter:=";" , Format:=4 If I rename the file as a text file, it works !!! If anyone has an idea, i want to...

parse cell and insert rows?
Is there a way in Excel to parse a cell that has a comma delimited values, and put each value into rows? In this situation, the cell with the delimited values can have a varying amount of values - and because of formatting issues, I would like to insert new rows. Example: CELL A1: 10,11,12 CELL A2: 10 CELL A3: 11 CELL A4: 12 Any help would be greatly appreciated! /grod You can use text to columns to parse the string, then copy/paste special>transpose to get them into rows. "Gorrila Grod" <grod@no.thanks.com> wrote in message news:2004110210394316807%grod@nothan...

exporting Excnage 5.5 directory to CSV
Hey All, I'm running Exchange 5.5 and need to be able to export the directory into the CSV format via command. Using Tools --> Directory Export option works fine, however i need the command line alternative. So far i'm not able to find one. Can someone help please? Thanks Alex Have you tried using the /e command line option of the Exchange 5.5 Admin.exe? Run Admin.exe /? to get the usage. --Chris ============================================================================ ==== This posting is provided "AS IS" with no warranties, and confers no rights. Use of any inc...

How to make one CSV file from two Excel sheets?
I have a huge database with about 400 columns. They are divided into two sheets - due to Excel limitation 256 columns in one sheet. I need to make one CSV file from these both sheets. The last column of first sheet should be followed by the first column of the second sheet. Is there any way how to do it directly from Excel? Or do you know any simple utility that can put together two CSV files exported from Excel? Thanks for any help Marek L. That sort of stiching can only be done using a hex editor. (And not all hex editors are created equal.) I did a quick search on the web and ther...

Exporting to csv file
I have a spreadsheet that's 625 rows x 11 columns the first 4 columns are populated in all rows. The problem is that the remaining 7 columns have no data in them but need to be imported by another program showing a "null" in those columns. Try as I might, Excel will only put commas at the ends of the first 16 records after which it ceases to do this. We get the message that Excel "may contain features that are not compatible with CSV". When the file gets to the other end, needless to say, it's pretty much useless. How do I get Excel to recognize all th...

import file so that it is a actual csv file, no excel cell version
How can I import a spreadsheet file from finance.yahoo.com for the history prices of a stock and import it into my charting software. My charting software reads ASCII "DOHLCV" or D,O,H,L,C,V or "Date", "O", "H", "L", "C", "V" . I have tried for a week trying to manipulate the data to be read by my charting software but it will not take it. When downloading data it automatically opens excel 97 spreadsheet and inserts the data. I save it as a CSV file but my charting program will not read it and when I open the fil...

XLS to CSV Exporting to Outlook
I am trying to export a xls file from Excel 2007 to Outlook 2007. How the heck do you convert it to a csv? I used to do it in the Y2K version of office! Thanks in advance! I don't use 2007 but can't you just do a File>Save As *.csv in Excel? Gord Dibben MS Excel MVP On Mon, 2 Jun 2008 16:56:57 -0500, "John" <ou12@msn.com> wrote: >I am trying to export a xls file from Excel 2007 to Outlook 2007. How the >heck do you convert it to a csv? I used to do it in the Y2K version of >office! >Thanks in advance! > I wish it was that easy, There is...

CSV import, excel corrupts data
Hello group, I'm one of the many struggling with excel's csv-import functionality. After reading through this group and trying out various things I'm not much wiser so I try to ask for a solution. I have an application that creates a cvs file for the user with some data. One of the columns can contain data that looks like this: "12/76" - unfortunately excel violates the cvs-spec and does interpret this as a (incomplete) date. It then displays "01.12.1976" for example, which is just plain wrong and must not happen. I tried the trick with a macro that marks all...

Parsing a stream for a txt that contains a space
Hi, I'm working on a script that analyses backuplogs. When a verify of an NTbackup is successfull, the logfile has a line saying: "Different :0" <snip> Directories: 4 Files: 0 Different: 0 Bytes: 176.150.718.504 Time: 2 hours, 46 minutes, and 39 seconds </snip> When I use the technique below to look for "Different: 0" in that stream, it comes up zero. Set oTextStream=logfile.OpenAsTextStream content=oTextStream.ReadAll .... if instr(content, "Different: 0") > 0 then The space between : and 0 is t...

Save as CSV not saving the same from Excel 2007 then in Excel 2003
If I take an Excel file and Save it as a CSV in Excel 2003 the blank rows from the Excel file show up on the CSV as blank rows (no commas show in that row) But when I save the same file in Excel 2007 (which we recently upgraded) the blank rows from Excel show up as about 15 commas on the CSV file. There are also other rows of data in the CSV file that have 5-10 extra commas appended to the end. Is there an option in Excel 2007 to save as CSV file but exclude blank rows? I can confirm that xl 2003 saves blank rows as blank rows while xl2007 saves them with commas and seems ...

importing .csv file as text with line breaks preserved
This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig586B1CBB78607B22F70A4995 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm trying to import a .csv file where some fields are numbers with leading zeros, and others have embedded line breaks. If I name the file with the .csv extension, the line breaks within fields are preserved, but the leading zeros are missing because every field is interpreted as General instead of Text. If I name the file with the .txt extension, I can manually change fields to Text as appropriate, but I can...

how to convert excel's .cvf file to .csv file
...

Trying to parse OpenDocument files (sxw)
Iam trying to read in sxw files and generate a preview for it. The problem now is that the file "content.xml" seem to contain a DTD. I do not want to process this DTD because this is a separate file which is not available at this time. I tried everything, but no matter what I do I get errors that the DTD is not found or cannot be accessed due to security reasons. Can't I deactivate usage of the DTD? XmlReaderSettings s = new XmlReaderSettings(); s.IgnoreComments = true; s.IgnoreWhitespace = true; s.IgnoreProcessingInstructions = true; s.ValidationType = ValidationType.None; ...

Can I open a csv file with xls extension in Excel 2002?
It works on Excel 97, 2000, but not 2002. Thanks! Does this mean you can't open it via File|Open or by double clicking on the file in windows explorer? Or something else? A little more info will get you a better response. Geoff wrote: > > It works on Excel 97, 2000, but not 2002. > > Thanks! -- Dave Peterson ec35720@msn.com ...

Address parsing algorithm needed please
Hi, I'm looking for an Address parsing algorithm in VB6/VBA, preferably for UK addresses. I want to replicate what Microsoft Outlook does if you paste an complete address in the address field of a Contact record when the Check Details box pops up with an estimated parsing into Street, City, Region etc. (Have Googled to no avail.) TIA "Jon Lewis" <jon.lewis@cutthespambtinternet.com> wrote in message news:echZfgh4KHA.4156@TK2MSFTNGP06.phx.gbl... > Hi, I'm looking for an Address parsing algorithm in VB6/VBA, preferably > for UK addresses. ...