Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
VictorFaure
Contributor II
Contributor II

Read string column as CSV file

Hello,

I'm currently working on a job which calls an API that returns a String which is actually a CSV file. To read the CSV file properly the job currently creates a temporary file, writes the string in the temp file and then reads from it.

I'd like to know if I can somehow convert the string to the CSV schema (more) directly.

Thanks.

Labels (3)
1 Reply
fcolagiacomo
Contributor III
Contributor III

I thought the solution below (in attachment the screenshot:

tJavaFlex: it simulates a file CSV as string

tNormalize: it splits the tJavaFlex's output by LF character (\n). You get every single row of CSV.

tExtractDelimitedFields: it splits each row by character ";" and you get every field of row 

Eventually, you need to remove double quote from string but it will be easy to do.

Components configuration

tJavaFlex: row5.contentFile="headerCol1;headerCol2;headerCol3\n\"text11\";\"text12\";\"text13\"\n\"text21\";\"text22\";\"text23\"\n\"text31\";\"text32\";\"text33\"\n\"text41\";\"text42\";\"text43\"\n";

tNormalize: set delimiter as "\n" and you have to flag "Discard the trailing empty strings" in Advanced settings, this is useful whether your file close as "\n" character.

tExtractDelimitedFields: set "fields separator" as ";", flag check every row structure of schema.

The schema output have every single field.

I hope this is useful.