--- title: "system.dataset.fromCSV" description: "Converts a dataset stored in a CSV formatted string to a dataset that can be immediately assignable to a dataset property in your project." --- # system.dataset.fromCSV > Converts a dataset stored in a CSV formatted string to a dataset that can be immediately assignable to a dataset property in your project. This function is used in **Python Scripting**. ## Description Converts a [dataset](platform/scripting/python-scripting/variables-datatypes-and-objects/datasets.md) stored in a CSV formatted string to a dataset that can be immediately assignable to a dataset property in your project. Usually this is used in conjunction with [system.file.readFileAsString](appendix\scripting-functions\system-file\system-file-readFileAsString.md) when reading in a CSV file that was exported using [system.dataset.toCSV](appendix\scripting-functions\system-dataset\system-dataset-toCSV.md). The CSV string must be formatted in a specific way: ``` #NAMES Col 1,Col 2,Col 3 #TYPES I,str,D #ROWS,6 44,Test Row 2,1.8713151369491254 86,Test Row 3,97.4913421614675 0,Test Row 8,20.39722542161364 78,Test Row 9,34.57127071614745 20,Test Row 10,76.41114659745085 21,Test Row 13,13.880548366871926 ``` The first line must be #NAMES. The second line must list the names of the columns of the dataset separated by commas. The third line must be #TYPES. The fourth line must list the type of each column of the dataset in order, separated by commas. |Data Type|Alias| |---|---| |byte.class|`byt`| |short.class|`s`| |int.class|`i`| |long.class|`l`| |float.class|`f`| |double.class|`d`| |bool.class|`b`| |Byte.class|`Byt`| |Short.class|`S`| |Integer.class|`I`| |Long.class|`L`| |Float.class|`F`| |Double.class|`D`| |Boolean.class|`B`| |Object.class|`O`| |Color.class|`clr`| |Date.class|`date`| |Cursor.class|`cur`| |Dimension.class|`dim`| |Rectangle.class|`rect`| |Point.class|`pt`| |String.class|`str`| |Border.class|`border`| The fifth line must be #ROWS followed by a comma and then the number of rows of data (i.e. #ROWS, 6). The following lines will be your data, each column value separated by a comma, and each row on a separate line. The number of rows must match what was specified on line 5. ## Client Permission Restrictions This scripting function has no [Client Permission](../../../ignition-modules/vision/vision-project-properties/vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.dataset.fromCSV( csv )` ### Parameters Type | Parameter | Description ------- | ------- | ------- String | `csv` | A string holding a CSV dataset in the format outlined above. ### Returns **Dataset** - A new dataset. ### Scope Gateway, Vision Client, Perspective Session ## Code Examples ```python title="Code Snippet" # This example assumes the CSV file being read was a dataset exported # using system.dataset.toCSV with the forExport flag set to True # Specify file path. file_path = "C:\\my_dataset.csv" # Read in the file as a string. data_string = system.file.readFileAsString(file_path) # Convert the string to a dataset and store in a variable. data = system.dataset.fromCSV(data_string) # Assign the dataset to a table. event.source.parent.getComponent('Table').data = data ```