Import CSV data line by line into DB

Hi there,

I've been looking for a way to read a CSV file line by line and store that (without any processing) in an Entity. So, each line of the CSV would be a new row in that entity. 

Can anyone provide me any input on how to achieve this? I've already seen some forge components for CSV files, but they all already do some kind of processing and do not allow me to achieve what I want.

Thanks.

Hi Ana,

Have you tried opening you CSV in Excel save it like an .xlsx file and bootstrap it to your entity? This link shows you how to bootstrap Excel documents

Hope it helps!

You can use the CSVUtilExtension from the forge.

The issue here is that the number of columns (and the columns' names/values) of the CSV will vary, so I first need.

To illustrate my use case, imagine the following scenario:

  1. A user answers an online survey
  2. The surveys answered on each day will be stored in a CSV (so, each line of the CSV will represent an answered survey)
  3. There are several types of surveys (with different set and amount questions) - each CSV file will represent a survey (e.g.: SurveyA.csv, SurveyB.csv, SurveyC.csv, ...)

That being said, I was thinking of importing the data "as it is" into a temporary Entity (in which each line of a given CSV would be a new entry in the Entity - with all the separators). Then I would do the processing based on the separators and configurations of the surveys.

From what I've seen in forge (including CSVUtilExtension component that Stefano suggested), all these components already do some kind of processing, assuming a fixed number of columns,

Please let me know if I wasn't clear with my scenario.

Thanks


Not exactly. you can make a structure with a list of text records

when you define the endline as delimiter you will get each line as 1 record in your list.

Stefano Valente wrote:

Not exactly. you can make a structure with a list of text records

when you define the endline as delimiter you will get each line as 1 record in your list.

I tried your suggestion, using "/n" as the delimiter (NewLine() or Chr(13) wouldn't work), but I noticed that if I have a line like "9/10/2018" only the 9 will be stored for that line, because of the "/". Do you have any idea on how to overcome this issue?

The trick is to use a delimiter that your line doesn't have. | could also be a good choice.