利用python 模块读取csv文件信息
还有一个比较简单的方法
# -*- coding=utf-8 -*- import pandas as pd
df = pd.read_csv("20170320094630.csv",encoding="gb2312")
print("df is \n",df)
标黄的地方,切记,切记
import unicodecsv
enrollments_filename = '/datasets/ud170/udacity-students/enrollments.csv'
## Longer version of code (replaced with shorter, equivalent version below)
# enrollments = []
# f = open(enrollments_filename, 'rb')
# reader = unicodecsv.DictReader(f)
# for row in reader:
# enrollments.append(row)
# f.close()
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.
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]
利用python 模块读取csv文件信息的更多相关文章
- Python中读取csv文件内容方法
gg 224@126.com 85 男 dd 123@126.com 52 女 fgf 125@126.com 23 女 csv文件内容如上图,首先导入csv包,调用csv中的方法reader()创建 ...
- python之模块csv之 读取CSV文件(reader和DictReader2个方法)
# -*- coding: utf-8 -*- #python 27 #xiaodeng #读取CSV文件(reader和DictReader2个方法) import csv #csv文件,是一种常用 ...
- Python 读取csv文件到excel
朋友问我如何通过python把csv格式的文件另存为xls文件,自己想了想通过读取csv文件然后再保存到xls文件中即可,也许还有其他简单的方法,但这里也为了练习python语法及其他知识,所以采用了 ...
- [Python Study Notes]pd.read_csv()函数读取csv文件绘图
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- python 使用read_csv读取 CSV 文件时报错
读取csv文件时报错 df = pd.read_csv('c:/Users/NUC/Desktop/成绩.csv' ) Traceback (most recent call last): File ...
- Python读取 csv文件中文乱码处理
需求:按行解析读取csv文件存入关系型数据库——主要是中文字体解析:遇到的问题:直接解析出来的数据为list形式,而且编码格式为unicode;解决问题:前提了解: 中文编码的规则 —— GB2312 ...
- Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal multibyte sequence
Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal mul ...
- python中configparser模块读取ini文件
python中configparser模块读取ini文件 ConfigParser模块在python中用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(se ...
- python之小应用:读取csv文件并处理01数据串
目的:读取csv文件内容,把0和1的数据串取出来,统计出现1的连续次数和各次数出现的频率次数 先读取csv文件内容: import csv def csv_read(file): list = [] ...
随机推荐
- 007-mac快捷键
锁屏:Ctrl + Command + Q touch-bar:方法:“系统偏好设置”>“键盘”>“自定Control Strip…”,将“锁定屏幕”图标拖拽到Touch Bar上即可.] ...
- c++中字符串反转的3种方法
第一种:使用algorithm中的reverse函数 #include <iostream> #include <string> #include <algorithm& ...
- python16_day25【crm】
一.CRM模拟admin功能 1.过滤功能 2.显示数据分页 3.动态菜单 项目:https://github.com/willianflasky/growup/tree/master/s16/hom ...
- Python(socket编程——1、理论)
Socket的英文原义是“孔”或“插座”.作为BSD UNIX的进程通信机制,取后一种意思.通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机 ...
- A simple windows programm in c
A simple windows programm in c The following programm is a minimal windows program. It opens ...
- Postman 把response的值自动放到变量里
@ 1里面定义个变量2 3这里加上postman.setEnvironmentVariable("MatchID",JSON.parse(responseBody)); 这样rep ...
- quartz (二) Spring+Quartz实现定时任务的配置方法
JobDetail 设置执行的任务 :CronTrigger 触发器:设置执行的时间规则 ; Scheduler // 调度器,将任务与执行时间关联 本文转自:http://w ...
- laravel 环境配置
一.composer 安装 1.确定为最新版本的PHP 2.进入Composer官网下载页面,在页面最下方Manual Download区域选择需要的版本下载. 3.将下载的composer.phar ...
- 在python3下对数据分块(8x8大小)使用OpenCV的离散余弦变换DCT
在MATLAB中有blkproc (blockproc)对数据处理, 在python下没找到对应的Function, 这里利用numpy 的split(hsplit和vsplit) 对数据分块处理成8 ...
- Html遮罩层的显示(主要在于样式设置)
<html> <head> <title>aaa</title> <script type="text/javascript" ...