76
Views
26
Comments
Solved
I need to get the particular values from csv file
Question
Application Type
Reactive

Hi team 

I have an doubt to implement. Actually my requirement is I have an text file that contains the format of 10,1222,124578,12356,status 

More that 5 records. Here I need to get that third and status values in the form of table. 

What I do means I am converting the binary file to text format after that I call the string split after that I am blank canvas you anyone help me to fix this 


If anyone have any practiced oml means please share 


Thanks in advance 

Karthick 

2024-01-04 15-15-51
Abed Al Banna
Solution

For that you need to modify the TextFile server action as follows:

And the UploadOnClick:



I will attach the OML to this reply.


Parsing.oml
2024-01-04 15-15-51
Abed Al Banna
Solution

1. Create a new entity to store the data inside

2. Call the "Create" server action

3. Pass it the IMEI and the Status as inputs

4. This is the general idea, but of course you have to clean up the code later on once you get it to work, and isolate these elements into separate server actions.

2023-07-17 04-42-12
Karthick Balaji
Solution

awesome it is working superb tq so much  for you time.


thanks and regards

karthick balaji

2023-10-21 19-42-11
Tousif Khan
Champion

Hello @karthick B 

You can check this component this will help you - CSVUtils

Also if you want the specific value from the comma-separated string, As you have already used string split, it will return you a list, so you can use the list and with the help of row index or row number you can get the desired row result.

I hope if I understand the question correctly this will help you.

Thanks
Tousif Khan

2023-07-17 04-42-12
Karthick Balaji

for your reference i have attached the oml file 

Parsing.oml
2023-07-17 04-42-12
Karthick Balaji

here what i am trying to do means,

i am uploading the text file as a binary values i am converting the binary to text. after that i am calling the string split with help this i am able split the text.

please check the oml file here i am getting the extra empty records in output like this please help me this one.

Parsing.oml
2024-01-04 15-15-51
Abed Al Banna

Hi @karthick B 

Have you tried adding an extra If statement  to the action flow, before you append the values to the list?

I added the statement in the flow below, for your reference:

I set its condition to:

String_Split2.List[0].Text.Value = 0

 and

String_Split2.List[1].Text.Value = 0

 and

String_Split2.List[2].Text.Value = 0

 and

String_Split2.List[3].Text.Value = 0

 and

String_Split2.List[4].Text.Value = 0


You might want to slightly change the condition according to your logic.


I hope this helps!

2023-07-17 04-42-12
Karthick Balaji

i have tried that one but it's not working 

2024-01-04 15-15-51
Abed Al Banna

Can you share with us what the content of the file looks like? A screenshot would be enough

2023-07-17 04-42-12
Karthick Balaji
2024-01-04 15-15-51
Abed Al Banna

It's clearer now, the issue is caused by the additional empty strings you are getting after splitting the string based on the "NewLine".

To solve this, simply add this condition to the If statement I mentioned above:

String_Split2.List.Current.Text.Value = ""

You do not need the other conditions, this one is enough on its own.



Let me know if it works for you now :)

2023-07-17 04-42-12
Karthick Balaji

yes it working fine tq so much 

do you have any idea to extract the column from this text file 

2024-01-04 15-15-51
Abed Al Banna

Glad to hear that! 

Can you elaborate further on what you're trying to achieve?

2023-07-17 04-42-12
Karthick Balaji

yeah sure 

as of now it's good after that what i am trying to do means,

i have an proper text file from this text file i need to extract the IMEI and status as separate file in the form of excel.

also i Need to have a record of all the uploaded files and extracted outputs.

any idea of this to achieve 

2023-07-17 04-42-12
Karthick Balaji

also if i am uploading the file it contains more records while storing into db means i am able to store one record remaining records i am not able to get that 

any idea for this one to fix.

2024-01-04 15-15-51
Abed Al Banna
Solution

For that you need to modify the TextFile server action as follows:

And the UploadOnClick:



I will attach the OML to this reply.


Parsing.oml
2023-07-17 04-42-12
Karthick Balaji

tq so much it is working awesome but already i have an idea about this now i am clearly understood this downloading tq so much .

but my question is i want to store those data's in my db.

i am tried one way while uploading i am able to store but i am able to store one record remaining records i am not able to get it if you have any idea on this. 

2024-01-04 15-15-51
Abed Al Banna
Solution

1. Create a new entity to store the data inside

2. Call the "Create" server action

3. Pass it the IMEI and the Status as inputs

4. This is the general idea, but of course you have to clean up the code later on once you get it to work, and isolate these elements into separate server actions.

2023-07-17 04-42-12
Karthick Balaji

but in this case in Db it can store one record but uploaded file will have many records know i am able to get one record that is issue 


thanks and regards 

karthick balaji

2024-01-04 15-15-51
Abed Al Banna

This works for all rows/records inside your Text file. Try it out and let me know if it does the trick!

2023-07-17 04-42-12
Karthick Balaji
Solution

awesome it is working superb tq so much  for you time.


thanks and regards

karthick balaji

2023-07-17 04-42-12
Karthick Balaji

hi team i want to remove the last record from the text file 


can you help me to fix this i am able to remove the first one but i am not able to remove the last one for your reference i have attached the OMl file 

DataParse.oml
2024-01-04 15-15-51
Abed Al Banna

Hi,

What do you mean by "remove"? And which last record are you referring to? Please elaborate on what you are trying to accomplish here.

2023-07-17 04-42-12
Karthick Balaji

this is my text file i need to ignore first and last of the records while uploading please help me to clear the issue even that first record doesn't store in DB but the last record stored in DB as well i dont need that 


i dont want this is DB as well that first record for your reference i have attached the OML 


thanks and regards

karthick balaji

2024-01-04 15-15-51
Abed Al Banna

Hi,

attaching below the OML of the required solution. Refactored all the logic you had in there into a much simpler and cleaner approach, also modified the home-screen slightly in order to show the uploaded data, I also disabled the download of the resulting excel file (you will have to enable that again). The main thing you have to copy into your application is the new TextFile server action, this is the new flow:

I hope this helps!


Best,

Abed

DataParse.oml
2023-07-17 04-42-12
Karthick Balaji

if you dont mine can you try this csv file to upload 

GSMA-28-06-23.csv
2024-01-04 15-15-51
Abed Al Banna

One minor modification, please modify the Text assign as such:

You will have to remove all "" generated by the CSV using the Replace function.

Replace(BinaryDataToText(BinaryData,Encoding:), """", "") 


2023-07-17 04-42-12
Karthick Balaji

tq so much brother i learn lot many things from you you are rocking 

have you have any idea for validation if insert a file contains wrong data

2024-01-04 15-15-51
Abed Al Banna

You will have to figure that out and define it as per your use case, you can try to validate each field on its own (example: If Length(spliting_the_contained_values.List[0].Text.Value)<4 then...).

My advice for you is to learn through trial and error, keep trying things out until you reach a desired output, you can always refer to the forum for any new questions. Meanwhile, feel free to close this thread as the main targeted issue has been resolved, open new threads in case needed.

I hope this helped, best of luck!

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