How to read line by line from uploaded file

How to read line by line from uploaded file

  

I upload one file from UI. And at the back-end, I only receive a binaryData object. How can I read line by line from the binaryData?

There's a system extension called BinaryData which has a method BinaryDataToText. After you get the text, you can split it by lines, by using the Text extension's method String_Split.

João Pedro Abreu wrote:

There's a system extension called BinaryData which has a method BinaryDataToText. After you get the text, you can split it by lines, by using the Text extension's method String_Split.

Thank you for your reply. But if the file size is very large (maybe 300MB), can it work correctly? 


Hi Clarie chan,

I suggest you to do with your own Extension either in Java or .Net which comfortable .

 

You might want to split the file into smaller ones. I dont know what kind of processing you'll be doing with the file but 300mb might time out. 

claire chen wrote:

João Pedro Abreu wrote:

There's a system extension called BinaryData which has a method BinaryDataToText. After you get the text, you can split it by lines, by using the Text extension's method String_Split.

Thank you for your reply. But if the file size is very large (maybe 300MB), can it work correctly? 




For a very large file the method I mentioned may cause "out of memory" exceptions. You may also have some trouble uploading a 300MB file from the UI.

I'll assume you already have a solution for the upload, since the question isn't about that. After that I would suggest you write the uploaded file to the filesystem using the Network File System extension and then read a few lines of the file at a time. Network File System has a method called File_ReadTextLines that will read the whole file as lines at a time, but that is pretty much the same as doing a string split, so you'll probably need to create an extension based on that which allows you to specify the number of lines you want to read and the starting point. I had to do that a fews ago; I'll post the code here, if I can find it.