frictionlessdata / datapackage-py

A Python library for working with Data Packages.
https://frictionlessdata.io
MIT License
189 stars 44 forks source link

The result that "print(resource.headers) # ['city', 'location'] ", is not "['city', 'location'] ", but None. #236

Closed Leeeeeee001 closed 5 years ago

Leeeeeee001 commented 5 years ago

The result that "print(resource.headers) # ['city', 'location'] ", is not "['city', 'location'] ", but None. code: from datapackage import *

path = r'https://raw.githubusercontent.com/frictionlessdata/datapackage-py/master/data/data.csv' resource = Resource({'path': path}) print(resource.tabular) # true print(resource.headers) # ['city', 'location'] print(resource.read(keyed=True))

result: True None [{'city': 'london', 'location': '51.50,-0.11'},................

roll commented 5 years ago

@Leeeeeee001 Thanks! I have fixed the readme: you need to read data first to get headers.

roll commented 5 years ago

Or more precisely - reading has to be started to get headers. E.g.

for row in resource.iter():
  resource.headers
  row