|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I have a problem to convert the txt file with header and spaces into MS excel or access. I have a dump data text file that contains fields and records. Each field has certain amount of characters. At the beginning of the file there are 20 lines of the main header. After the main header, the next 5 lines are the sub header. Main header is not redundant, but the sub headers are redundant inconsistently(meaning it can stop after different number of records). There is no pipe between the fields. At the end of every record there is a 'cls'. I am not familiar with data conversion. I am running in a big problem here! Please help me out if you have been dealing with file conversion. Is there any available code or module that I can use to modify adapting my needs?
GT |
|
#2
|
||||
|
||||
|
well, there are several ways to pull data from txt to xls or mdb, but all of the ones I know of are contingent on one of two things - either a delimiter, such as a comma or space or special character, or known length records. Without one of those two conditions, I wouldn't know how to begin to tell you how to parse it.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
||||
|
||||
|
OK, there is a blank line at and the word 'cls' at the beginning and the end of the record. There are certain amount of characters reserve for each field. All field are separated by tab.
Please look up the attachement for an example. Thanks, GT |
|
#4
|
||||
|
||||
|
ok, is this the output or the input. Is this an existing format that some company has that you can't change, or can you change the way this done? Usually tab delimited files only have one tab between files
|
|
#5
|
|||
|
|||
|
U can read each line in this file,and analyse this line to get some information,input this information into a variable in vb..When u have read a line of this file in a variable,u can put this variable into excel or access...
Read file plz visit www.msdn.com and find file system object to get some knowledge.. |
|
#6
|
||||
|
||||
|
cp- the file system object is really necessary for file input from a text file. If you have any kind of delimiter, then you can use the split function on a temporary variable to produce an array.
|
|
#7
|
||||
|
||||
|
First of all, I appreciated for all of the responses. The attachment was the input. I just want to give you some examples and ideas about how my text file looks like. The out put could be either .xls or .mdb. The reason I change the name of the data because this is a confidential info. As long as I have some program to convert the current input, I can tweek the program to adapt my needs.
GT |
|
#8
|
||||
|
||||
|
well... you can read this file into an array of strings one line at a time, where one array object represents one line of text. The only problem with this is separating the text out. This file doesn't lend itself to flat-file databases very well, since the formatting isn't consistent. I'm guessing that this is predefined and you can't change it?
|
|
#9
|
|||
|
|||
|
2 way is same...Fisherman & i can help u!If u meet some trouble in read file!...:->
|
|
#10
|
||||
|
||||
|
Thank you both of you for the offer. Anyway, if you open the file in wordpad you will see its layout. It doesn't have consistent data, but it has consistent reserved characters. Please help me out to read the data. I am not familiar with data conversion programming. Thanks
GT |
|
#11
|
|||
|
|||
|
Yes,I know!..I have read your post file.It's have a Field name in the top of the file.U can read each line from this file except the field name line,and analyse this line to get some field value according the field name line content..
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > convert txt file into excel or access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|