Skip to content

Instantly share code, notes, and snippets.

@basicavisual
Created June 5, 2018 03:13
Show Gist options
  • Save basicavisual/5c782896721905f50219c2f08b9b341e to your computer and use it in GitHub Desktop.
Save basicavisual/5c782896721905f50219c2f08b9b341e to your computer and use it in GitHub Desktop.
from pyquery import PyQuery as pq
file = open('i44013001o2003.xlsx', 'r', errors='ignore').read()
doc = pq(file)
list = [ table.text() for table in doc('table').items() ]
data = [list[2], list[4], list[6], list[8]]
countries = []
for i in range(len(data)):
lenghts = data[i].split('\n')
countries.append(int((len(lenghts) - 14 ) / 13))
print(countries)
print(data[0])
dic = {next[13]:{}, next[26]: {}, next[39]:{}, next[52]:{}, next[65]:{}, next[78]:{}}
print(dic)
len(next)
print(next)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment