cancel
Showing results for 
Search instead for 
Did you mean: 

Reading each row of a .csv file in 12.1

Former Member
0 Kudos

I have a .csv file with the first row as header information and multiple data rows. I aim to insert the data rows into SQL database. The functionality works fine with MII 11.5, where I loaded the content using a text loader and used a flat file parser to retrieve each row. But 12.1 the flat file parser gives me a single row with all the header and value data separated by commas. How can I read each row of the *.csv to make my database insert possible? Please help!

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member192939
Active Participant
0 Kudos

Ajitha,

Should be a simple one ..

1. Use flat file parser

2. Repeater on Flat file parser Ex:Flat_File_Parser_0.Output{/Rowsets/Rowset/Row/Line}

3. String List to XML ..

Regards,

Ajay.

Former Member
0 Kudos

Ajay,

After migration to 12.1, the functionality u have mentioned has stopped working. The flat file parser returns a single Line with all the column and row values separated by commas. It does not return a <Line> tag corresponding to each row in the csv. It does not recognize the new line start.

0 Kudos

Ajitha,

You can always use this custom action to parse your document...

[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0c1f975-f163-2d10-a596-c1c9ef91f2d6|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0c1f975-f163-2d10-a596-c1c9ef91f2d6]

Sam

former_member192939
Active Participant
0 Kudos

Ajitha,

Its working on our server.

Update to the latest patch .. i guess now it is SP 05 Patch 11 ..

Regards,

Ajay.

Former Member
0 Kudos

If you know the number of columns you could put the whole thing into a String List to XML action and parse your data dynamically using something like Rownumber*Colnumber. You could get the Rowcount by String List Rowcount/numcols to use in a For Next Loop.

Former Member
0 Kudos

@ Sam,

This should help me. thanks!

@ Christian Libich,

Checking the number of columns in the first row is also a part of the requirement. I may have to reject files that have incorrect number of columns. this restricts me from checking the string list output / expected column count. If I expect 10 columns in the first row and the string list gives me a total of 100 columns, I will not be able to decide if it is a csv with 10 columns and 10 rows (good file) or 20 columns with 5 rows (bad file)

@ Ajay,

Got to check this.

Thanks!