Created
April 23, 2013 19:45
-
-
Save ivanelson/5446783 to your computer and use it in GitHub Desktop.
Read files CSV with column named.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- encoding: utf-8 -*- | |
# By Ivan | |
import sys, csv | |
from decimal import Decimal | |
from datetime import datetime | |
def csv_columnames(): | |
data = csv.reader(open('entgara.csv'), delimiter=';') | |
#Read the column names from the first line of the file | |
fields = data.next() | |
for row in data: | |
# Zip together the field names and values | |
items = zip(fields, row) | |
item = {} | |
print items | |
# Add the value to our dictionary | |
for (name, value) in items: | |
item[name] = value.strip() | |
print 'Coluna: ',name | |
print 'Valor: ', value | |
print item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment