My CSV file:
sku,cost price
aba,8.32
abb,11.12
abc,34.34
abd,7.54
abe,3.54
abf,9.31
abg,8.22
What I am trying to do is creative a dictionary where the sku key returns its respective value, so {'aba':'8.32}, {'abb':'11.12'}
, etc.
My CSV file:
sku,cost price
aba,8.32
abb,11.12
abc,34.34
abd,7.54
abe,3.54
abf,9.31
abg,8.22
What I am trying to do is creative a dictionary where the sku key returns its respective value, so {'aba':'8.32}, {'abb':'11.12'}
, etc.
You can use pandas (pip install pandas
):
import pandas as pd
df = pd.read_csv('your_file_name.csv', index_col=0)
df.to_dict()['cost price']
Out:
{'aba':'8.32', 'abb':'11.12', ...}