This article describes what how to convert a file with an uneven amount of columns and how to create a file definition based upon the data.
Sometimes you may have a source file where every row does not contain the same number of columns. Below is an example of a point-of-sale CSV output file viewed in Notepad++:
As you can see here the top 6 rows only contain one column of data. Since not all rows contain the same number of columns, you will need to set up the File Definition for this data by defining that is has uneven rows.
When creating a File Definition for an uneven file you must create it with the correct amount of fields, or columns, for each row to make the field layout equal to the expected columns.
For example, if we look at our CSV file above we want to have row 8 (highlighted below) be our expected columns.
We would need to create the File Definition to define this amount of fields.
This can be accomplished by either creating the File Definition fields manually, or creating a sample file with the expected headers.
To create a File Definition for a file with uneven rows click on your initials in the upper-right corner and select Admin Console
Creating the File Definition from a sample file
detamoov can easily create the correct File Definition if you have a sample file of the correct number of expected columns in the file. Using our example file above, we created a sample CSV using the header on row 8:
On the Admin Console click the File Definition tab, click the New button and select 'Upload a sample File (csv)'
Click 'Upload Sample Input File' to select the sample CSV file.
Once the file is uploaded, the File Definition now contains all the fields we provided.
Next we provide a Name for our File Definition and then toggle the 'Uneven Rows' switch to the on position.
To save the File Definition scroll to the bottom of the page and click the Save Change button.
You have now created a File Definition that will accept the uneven rows. To be able to use the File Definition edit it and then toggle the 'Publish' option in the upper right to the on position.
Creating the File Definition manually
If you do not have a sample file you will need to create the File Definition by manually adding the correct amount of fields.
To create a manual File Definition, click on the File Definition tab, click the New button and select the Create New Definition option
On the New File Definition page provide a Name, select CSV as a File Type, select the delimiter and then toggle the Uneven rows switch to the on position.
Then for each field in the file click the Add Field button, provide a field name and set the field Type.
Once you have added all fields click the Save Changes button.
You have now created a File Definition that will accept the uneven rows. To be able to use the File Definition edit it and then toggle the 'Publish' option in the upper right to the on position.