Sheri
(Sheri)
February 28, 2019, 12:40am
1
Hi guys
I am trying to read a number in a CSV file.
The number will always be directly to the right of the field saying “Lodgement”, but where that pair of text appears in the rows will differ every time I need to read this file. It could be 2 rows down, it could be 10 rows down, etc.
Essentially, I want to grab the “123456” below.
Any ideas on how I can read the CSV, search for the phrase “Lodgement” and then only grab the number directly to the right of it?
venkat4u
(venkat)
February 28, 2019, 4:11am
2
@Sheri
Read CSV file activity - output is datatable
so you can read by column name and you can do your actions.
if the columns are not fixed then
Read CSV file activity - output is datatable
outputdatatable - output is String
if you know the row then you can find the index of the “Lodgement” using Datatable.Rows.indexof(“Lodgement”) then you can go cell by cell
Sheri
(Sheri)
February 28, 2019, 4:12am
3
For step 3, what activity do I use? Thx
Read CSV into DataTable (make sure Add Headers is included in the properties)
Filter the data table using DataTable.Select
If you are sure that always Lodgement is there in the CSV,
lodgementValue = myDataTable.Select("columnName1 ='Lodgement'")(0)(1).ToString
(0)(1) → 0 is the found row and 1 is the column index
If not,
Array of Data Rows, dr[] = myDataTable.Select("columnName1 ='Lodgement'")
If dr.Count > 0 Then
lodgementvalue = dr(0)(1).ToString
End If
Regards,
Karthik Byggari
1 Like
venkat4u
(venkat)
February 28, 2019, 4:16am
5
if you have the data like in latest image then please follow
Sheri
(Sheri)
February 28, 2019, 4:18am
6
What sort of activity should I be using?
Assign Activity.
Create a variable and assign.
venkat4u
(venkat)
February 28, 2019, 4:19am
8
you use assign activity
left hand side "lodgementValue "
right hand side = myDataTable.Select(“columnName1 =‘Lodgement’”)(0)(1).ToString
Sheri
(Sheri)
February 28, 2019, 4:20am
9
Thanks @KarthikByggari and @venkat4u I’ll give that a go!
Sheri
(Sheri)
February 28, 2019, 4:32am
10
Hi guys, I’m getting this error:
Here’s the assign I made (I need it to search for the full phrase, not just the word “Lodgement”:
Left : getDocumentNumber
Right : MyDataTable.Select(“columnName1 =‘Our Bank Document Lodgement’”)(0)(1).ToString
Would appreciate any further help!
Rashmi
(Rashmi Pareek)
February 28, 2019, 4:37am
11
Is your column name is “columnName1” ? in CSV File
Sheri
(Sheri)
February 28, 2019, 4:39am
12
No, the CSV looks like this:
Rashmi
(Rashmi Pareek)
February 28, 2019, 4:42am
13
So give like this : MyDataTable.Select(“Column-0 =‘Our Bank Document Lodgement’”)(0)(1).ToString
and make sure if it’s small c you have to give
MyDataTable.Select(“column-0 =‘Our Bank Document Lodgement’”)(0)(1).ToString
Try this
Sheri
(Sheri)
February 28, 2019, 4:50am
14
Same error I am afraid. Here’s my exact sequence:
AkshaySandhu
(AkshaySingh Sandhu)
February 28, 2019, 5:08am
15
Hello @Sheri
try to surround column name with “ ” square brackets like: [Column-0]
Rashmi
(Rashmi Pareek)
February 28, 2019, 5:09am
16
Try this : MyDataTable.Select(“[column-0] =‘Our Bank Document Lodgement’”)(0)(1).ToString
lakshman
(Ganta lakshman)
February 28, 2019, 5:16am
18
@Sheri ,
please find the attached workflow.Main.xaml (9.7 KB)
Regards,
Lakshman Ganta.
AkshaySandhu
(AkshaySingh Sandhu)
February 28, 2019, 5:24am
19
Hello @Sheri
did surrounding column name with square brackets worked for you…?
if yes then please mark you ques as resolved.
if no then let us know…
amr07
(Aravind)
February 28, 2019, 6:05am
20
Hi @Sheri Please find the attached workflow.I have used here “Filter data table” activity and result has been stored in a resulting data table.
Main.xaml (8.1 KB)
Regards