Skip to content
Snippets Groups Projects
Commit d97b51dc authored by BastianTigges's avatar BastianTigges
Browse files

fixed csv project

parent b262bbc8
Branches
No related tags found
No related merge requests found
......@@ -175,14 +175,8 @@ Setup
Let's start by setting up the project as usual, though in this short case we would not need all the extensions::
from instrument import Instrument
from model import Model
from parameter import Parameter
from dataset import Dataset
from pipeline import Pipeline
from run import Run
import numpy as np
import pandas as pd
from pykkn.dataset import Dataset
In this case, it is important to add the panda framework as well because we will use this to store the CSV file::
......@@ -192,20 +186,26 @@ In this case, it is important to add the panda framework as well because we will
Inserting and storing of the data
*********************************
At first, we will store the CSV file as a variable which we can then add to dataset object. To do this, we use the function read_csv() from the panda framework::
At first, we will store the CSV file as a variable which we can then add to dataset object. To do this, we use the function read_csv() from the panda framework.
In the parameters of the function you put the name of the csv file. In this case the table is stored in the same folder as the example project.
That is why no further import path is needed. The second paramter in this case is called "sep=;". Is specifies how the data in the csv table are seperated::
df = pd.read_csv("test_data.csv")
df = pd.read_csv("exampleTable.csv", sep=';')
Afterwards, we create a dataset object and add the df variable to this object::
dataset1 = Dataset("test_data.csv")
dataset1 = Dataset("from_csv_table")
dataset1.data = df.values
Before storing the hdf5 file set the storage path. In this case only a name is given::
dataset1.set_storage_path("from_csv_table.h5")
To create the HDF5 file from this, we use the store() function::
dataset1.store()
The output of this short project can be seen below:
The output of this short project can be seen below. By double-clicking on the "from_csv_table" object on the left you can open the window shwon in the left with stored data:
.. image:: user-images/example-project-importCSV/csv_file_hdf5.jpg
......
docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg

30 KiB | W: | H:

docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg

260 KiB | W: | H:

docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg
docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg
docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg
docs/source/user/user-images/example-project-importCSV/csv_file_hdf5.jpg
  • 2-up
  • Swipe
  • Onion skin
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment