192
Views
7
Comments
Read text file line by line
Question
Hello Intelligent people,

I have text file of specific format. I want to read it's contents line by line. Whenever my cursor comes at every line, I want to split that line and store splitted contents in database. 

Please advice how to read text files line by line.

Thanks.
2012-08-01 17-33-40
Gerry

Use the Split action of the Text extension
2018-11-06 14-26-44
Suraj Borade
Hi Gerry,

Thanks a lot for the reply.

I tried Splitting the text file using that action but my concern is that how would I come to know that my cursor has reached to next line.

Do you have any samples?
2012-08-01 17-33-40
Gerry
When you split the text on a delimeter, say line feed (char(10)) or carriage-return, line feed (chr(13)+chr(10)), each line will be seperate record in a record list. Use the For Each to iterate through the list to read each line.
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Hi Suraj, Gerry,

In I think Platform 4.2, there was a system component called "FileSystem" that had all kinds of nice stuff, including reading all lines of a file. Unfortunately, it was discontinued for unknown reasons. In the Forge there's at least one component that derives from this, maybe that's of use. There also another component that may also have this feature (reading lines), but I'm not certain.
2015-04-10 17-57-05
Pedro Coelho
 
MVP
FileSystem still exists, I just installed Html2PdfConverter yesterday and it has a dependency for FileSystem and installed it.

And yes it's the OS Staff maintained (even though it's not a featured extension), going way back

Best regards,
PC
2023-01-29 21-43-42
António Rodrigues
Hi Suraj Borade,

Don't know if this will work, but can you try to create an entitie,  with one record text leght. Then use advanced query to and load your file using sql to that expecific table, then you can work your records.

You can see in the link bellow, ho to create your specific bulk insert code, to your specific text file.
https://msdn.microsoft.com/en-us/library/ms188365.aspx

hope it helps
2018-11-06 14-26-44
Suraj Borade
Hello everybody,

Thanks a lot for replies.

I tried everything but splitting text on delimiter worked.

I used StringSplit action and applied chr(10) on delimeter. Now StringSplit is returning me RecordList and I am able to traverse through the record list.

Thanks a lot.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.