Skip to main content

Enable handle of csv, xls and xlsx files getting column header

Project description

The PyHeaderFile helps the work with files that have extensions csv, xls and xlsx.

This project aims reading files over the header (column names). With this module we can handle Csv, Xls and Xlsx files using same interface. Thus, we can convert extensions, strip values in lines, change cell style of Excel files, read a specific Excel file, read an specific cell and read just some headers.

Install

pip install pyheaderfile

How to use

Class csv

Read csv

file = Csv(name=’file.csv’)
for row in file.read():
    print row

Set Header

file.header = ['col1', 'col2','col3']

Create csv

file = Csv(name='filename.csv', header=['col1','col2','col3'])

Write list csv

file.write(['col1','col2','col3'])

Write dict csv

file.write(dict(header=value))

Class Xls

Read xls

file = Xls(name=’file.xls’)
for row in file.read():
    print row

Set Header

file.header = ['col1', 'col2','col3']

Create xls

file = Xls(name='filename.xls', header=['col1','col2','col3'])

Write list

file.write(['col1','col2','col3'])

Write dict

file.write(dict(header=value))

Class Xlsx

Read

file = Xlsx(name=’file.xlsx’)
for row in file.read():
    print row

Set Header

file.header = ['col1', 'col2','col3']

Create file

file = Xlsx(name='filename.xlsx', header=['col1','col2','col3'])

Write list

file.write(['col_val1','col_val2','col_val3'])

Write dict

file.write(dict(header=value))

Save file

file.save()

Modifying extensions, name and header

q = Xls()
x = Xlsx(name='filename.xlsx')
x.name = 'file'
x.header = ['col1', 'col2','col3']
q(x)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyheaderfile-0.2.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page