Datapot utilities

This notebook shows how you can save your time using datapot utils module's functions.

csv_to_jsonlines


In [1]:
import pandas as pd

df = pd.read_csv('../data/example_csv_file.csv', delimiter=';')
df


Out[1]:
id name surname sex
0 1 Alice Walker f
1 2 Mike Johnson m
2 3 Sam Chen m
3 4 Anna Ivanova f
4 5 Denis Kozlov m

In [2]:
from datapot.utils import csv_to_jsonlines

csv_to_jsonlines('../data/example_csv_file.csv', '../data/example_jsonlines_file.jsonlines', delimiter=';')

In [3]:
with open('../data/example_jsonlines_file.jsonlines', 'r') as ftr:
    for s in ftr.readlines():
        print(s)


{"id":1,"name":"Alice","surname":"Walker","sex":"f"}

{"id":2,"name":"Mike","surname":"Johnson","sex":"m"}

{"id":3,"name":"Sam","surname":"Chen","sex":"m"}

{"id":4,"name":"Anna","surname":"Ivanova","sex":"f"}

{"id":5,"name":"Denis","surname":"Kozlov","sex":"m"}

In [ ]: