Help with Python


#1

I am trying to call a CSV File , and creating a new column based on truncated strings of an existing column using Python.

I have :

 import csv
from collections import defaultdict

columns = defaultdict(list) 

with open('file.txt') as f:
            for (k,v) in row.items(): 
            columns[k].append(v)

#2

but if you want to read and write from a csv file you need to use the csv writer and reader objects, as explained in the documentation:

https://docs.python.org/2/library/csv.html