Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read text File

Status
Not open for further replies.

lonchi

Programmer
Jan 30, 2002
12
MX
Does any one know what I need to do to read a specific *.text file and insert some data in a database!

The text file will look like this:
===================================
Set:1
Name: My name
Adress: My adress
Street: My street
Zip: My Zip

Set:2
Name: My name
Adress: My adress
Street: My street
Zip: My Zip

Set:3
Name: My name
Adress: My adress
Street: My street
Zip: My Zip
.
.
.
.... and so on!
==================================
 
save iut as a delimited text file and dump it into something - (excel)? and you can report off of that if you want to...

lmc
cryerlisa@hotmail.com
 
Text Files aren't databases, and cause problems if you expect them behave like one. Use a utility to get it into a DB somhow - MSAccess would be fine.

If you need to do a text file lookup, I've got a UFL that can lookup lines and columns in a text file. Development is completed, I've just got some documentation to write, so email me if you'd like to see a preliminary demo version. Editor and Publisher of Crystal Clear
 
the way I understand this, what lonchi is trying to do is bring some text data in and put it in the db, not make it behave like one..

I still think you could just get it into the db using access, or excel even, and then go from there...
 
test files can be data sources if they are configured properly and an ODBC Text driver is chosen

the format of the file MUST be like this:

FIRST LINE: Contains a comma delimited list of the Fields os the dat. Each fieldName is wrapped in Double Quotes(")
FOLLOWING LINEs: Each line is a record with the same order as shown in the previous line. Each value is comma delimited and Strings are wrapped in Double quotes and numbers are just comma separated

for example: test.txt


"EmpID","LastName","FirstName","YearsOfService","Dept"
"001","Doe","John",5,"Accounting"
"002","Smith","Sarah",2,"Marketing"
"003","NewGuy","Someone",,"Sales"

Note: the YearsofService for NewGuy is set to null

this form of data handling is treated the same as any database table...the same rules apply when designing your CR reports.

What I like about this format over importing into an excall spreadsheet is the simplicity of it all....I don't have to define and redefine an area on a spreadsheet in order for it to work. I MUST keep the name of the Text file the same if I change the data. But I can easily add more data...or a different file by simple renaming,

Often you see stored procedures creating temporay tables to report a Batch process result. The tables are purged after the Batch Process with the report printed to a designated printer.

The problem with this is that onely one person gets to view that data. I am proposing to the group I am working with that instead of Temporary tables...we use a text file instead. When the batch process is run again...the text file would be renamed using a time format so it can be identified and the DATA text file for the report is then rewritten.

This serves 2 purposes:

1. The Batch process report is available to other users. (currently, the proceedure would have to be rerun (takes an hour to run) for anyone who wants to see the data but doesn't get the autoprintout.
2. We retain the past history of the process...it is not lost since the file is renamed.

3. Archiving??? Winzip works for me :)

So...in summary...YES...Text files can be used as data sources if they are formatted properly. Thay are treated as any other table by CR. More than one can be used in one report. This is the way we launched a crystal report from VB3 years ago (creating text files and reporting against them)

I think they can be most advantageous in certain situations.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top