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.1.9.tar.gz (5.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page