利用 python 模塊 讀取 csv 文件 信息 欄目 Python 简体版
原文   原文鏈接

還有一個比較簡單的方法app

# -*- coding=utf-8 -*-

import pandas as pd
df = pd.read_csv("20170320094630.csv",encoding="gb2312")
print("df is \n",df)
標黃的地方,切記,切記

 

 

 

import unicodecsvui

enrollments_filename = '/datasets/ud170/udacity-students/enrollments.csv'this

## Longer version of code (replaced with shorter, equivalent version below)spa

# enrollments = []
# f = open(enrollments_filename, 'rb')
# reader = unicodecsv.DictReader(f)
# for row in reader:
# enrollments.append(row)
# f.close()code

with open(enrollments_filename, 'rb') as f:
reader = unicodecsv.DictReader(f)
enrollments = list(reader)

### Write code similar to the above to load the engagement
### and submission data. The data is stored in files with
### the given filenames. Then print the first row of each
### table to make sure that your code works. You can use the
### "Test Run" button to see the output of your code.utf-8

engagement_filename = '/datasets/ud170/udacity-students/daily_engagement.csv'
submissions_filename = '/datasets/ud170/udacity-students/project_submissions.csv'
def read_csv(filename):
with open(filename,'rb') as f:
reader = unicodecsv.DictReader(f)
return list(reader)

daily_engagement = read_csv(engagement_filename) # Replace this with your code
print daily_engagement[0]
project_submissions = read_csv(submissions_filename) # Replace this with your code
print project_submissions[0]ci

相關文章
相關標籤/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公眾號
   歡迎關注本站公眾號,獲取更多信息