473,287 Members | 1,659 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,287 software developers and data experts.

how to read data in text file, extract and display in tabular manner in excel doc?

hi, anyone can help me figure out how to read data from a text file
like this:

10980012907200228082002

and extract the data according to this kind of format:

Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
i would want the program to extract the data and display them like
this:

TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002

and to save them in an excel format. I have plenty of record types (0
- 9) and need to display them in separate tables.

does anyone has a source code for this? or at least somebody pls guide
me to figure out ways to create the program.

many thanks!

Jun 20 '07 #1
3 5663
ma******@gmail.com wrote:
hi, anyone can help me figure out how to read data from a text file
like this:

10980012907200228082002

and extract the data according to this kind of format:

Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
i would want the program to extract the data and display them like
this:

TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002

and to save them in an excel format. I have plenty of record types (0
- 9) and need to display them in separate tables.
The reading part is easy, but you'll have to ask in a windows group for
this bit.

--
Ian Collins.
Jun 20 '07 #2
<ma******@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
hi, anyone can help me figure out how to read data from a text file
like this:

10980012907200228082002

and extract the data according to this kind of format:

Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
i would want the program to extract the data and display them like
this:

TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002

and to save them in an excel format. I have plenty of record types (0
- 9) and need to display them in separate tables.

does anyone has a source code for this? or at least somebody pls guide
me to figure out ways to create the program.

many thanks!
Well, one thing you might want to consider doing is to save the data into a
CSV (comma seperated variable) file and open that in excel. Then you won't
have to worry about saving in excel format which can be a pain. But excel
can open a CSV file. In which case you would want to save the data so it
looks like this:

1,098001,29072002,28082002

You may also wish to put your header file first.
TY-RECORD,ID-PARTICIPANT,DT-START,DT-END

1,098001,29072002,28082002
Jun 20 '07 #3
On Jun 20, 3:38 am, "mayle...@gmail.com" <mayle...@gmail.comwrote:
hi, anyone can help me figure out how to read data from a text file
like this:
10980012907200228082002
and extract the data according to this kind of format:
Record type 1
TY-RECORD PIC (1).
ID-PARTICIPANT PIC (6).
DT-START PIC (8).
DT-END PIC (8).
i would want the program to extract the data and display them like
this:
TY-RECORD ID-PARTICIPANT DT-START DT-END
1 098001 29072002 28082002
and to save them in an excel format.
Does the data have to be converted into numeric types, or is it
sufficient to keep it as strings. If all you need is strings,
just read the record into a string, then use string::substr() to
extract the different fields. If you need to convert, you'll
have to start like this as well, then use istringstream to
convert the field to the target type. Because there are no
separators, you cannot use istream to convert before having
broken the data up into fields.

To display, you can just output using <<, but for tabular
output, something like boost::format might be easier to use,
once you learn the arcane format syntax. (The ideal would be
something like Basic's PRINT USING, but I don't know of anything
similar in C++.)

For Excel, the simplest would doubtlessly be a CSV format; just
output each line as sequence of comma separated values (or
semi-colon separated, if you are outside of the Anglo Saxon
world).
I have plenty of record types (0
- 9) and need to display them in separate tables.
In which case, it wouldn't be too hard to write a small program
which parses the Cobol record declarations into a simple C++
class, including a constructor which does the conversions.

Note that any "USAGE IS COMPUTATIONAL" will be BCD, and if the
Cobol is running on an IBM mainframe, the text may be EBCDIC.

You may also want to recognize some naming conventions. (In the
above, it looks like DT- might be dates, for example.)

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hugh McLaughlin | last post by:
Hello everyone and thanks for your help in advance. This is somewhat of a continuation of a thread that I posted about one week ago. the heart of the project requires using ADO.Net to extract...
4
by: see_mun_lee | last post by:
I use asp to develop a web page to read an excel file containing Chinese Character then display it in the web page. Unfortunately, I cant display it!!! it will display (?????????). <META...
2
by: Vanessa | last post by:
I need to read/extract data from an Excel file using ASP. However, the Excel file is not in regular tabular format; instead, it is actually a form. Therefore, it contains many checkbox and merged...
12
by: kath | last post by:
How do I read an Excel file in Python? I have found a package to read excel file, which can be used on any platform. http://www.lexicon.net/sjmachin/xlrd.htm I installed and working on the...
1
by: ashok0866 | last post by:
I had created a macro to read data from an excel sheet and write the values to a text file. I had used "ActiveSheet.Range("GB" & k).Value" command to read the values from the excel. The issue...
4
by: sukhmeet | last post by:
Hi, I am trying to load a csv file in Iframe element. I just want to load it as a text file. however when i load the file in iframe it asks to open the file and finally opens it with excel in IE...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
2
by: Riak | last post by:
Hellow Helpers: I am doing data entry job manually and data is huge. Now I was told to write/get some sort of program/script which can do this job quickly, otherwise I will loose job. I am good...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
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: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.