Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions llluiop/0015/city.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

import xlwt
import json


def load_data(filepath):
f = open(filepath, "r")
return json.load(f)

def write_data_to_xls(data):
xls = xlwt.Workbook()
sheet = xls.add_sheet("city")

print data
for i in range(len(data)):
sheet.write(i, 0, i+1)
json_data = data[str(i+1)]
sheet.write(i, 1, json_data)

xls.save('city.xls')


if __name__ == '__main__':
data = load_data("city.txt")
write_data_to_xls(data)




5 changes: 5 additions & 0 deletions llluiop/0015/city.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"1" : "上海",
"2" : "北京",
"3" : "成都"
}
Binary file added llluiop/0015/city.xls
Binary file not shown.
28 changes: 28 additions & 0 deletions llluiop/0016/number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

import xlwt
import json


def load_data(filepath):
f = open(filepath, "r")
return json.load(f)

def write_data_to_xls(data):
xls = xlwt.Workbook()
sheet = xls.add_sheet("number")

for i in range(len(data)):
for j in range(len(data[i])):
sheet.write(i, j, data[i][j])

xls.save('number.xls')


if __name__ == '__main__':
data = load_data("number.txt")
write_data_to_xls(data)




5 changes: 5 additions & 0 deletions llluiop/0016/number.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
[1,82,65535],
[20,90,13],
[26,809,1024]
]
Binary file added llluiop/0016/number.xls
Binary file not shown.