Skip to content

Commit 454d076

Browse files
committed
auto
1 parent 7c12d1f commit 454d076

15 files changed

Lines changed: 232 additions & 32 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Python tutorial - 18 - Read json file and save data to xlsx file/.idea/workspace.xml

Lines changed: 43 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python tutorial - 18 - Read json file and save data to xlsx file/input.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
{
1616
"x": 9,
1717
"y": 8
18+
},
19+
20+
{
21+
"x": 100,
22+
"y": 120
1823
}
1924
]
20-
}
25+
}

Python tutorial - 18 - Read json file and save data to xlsx file/main.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ class FileManagement:
77
def __init__(self):
88
self.json_file_name = "input.json"
99
self.excel_file_name = "output.xlsx"
10-
self.reset_data()
11-
12-
def reset_data(self):
1310
self.array_x = []
1411
self.array_y = []
1512
self.array_sum = []
@@ -27,26 +24,20 @@ def read_text_file(self):
2724
self.array_sum.append(x + y)
2825
pprint.pprint("x = {0}".format(x))
2926
pprint.pprint("y = {0}".format(y))
30-
3127
except:
3228
print("Unexpected error : ", sys.exc_info()[0])
3329
raise
3430

3531
def save_to_xlsx(self):
36-
workbook = xlsxwriter.Workbook('demo.xlsx')
32+
workbook = xlsxwriter.Workbook(self.excel_file_name)
3733
worksheet = workbook.add_worksheet()
38-
worksheet.set_column('A:A', 20)
3934
for index, value in enumerate(self.array_x):
40-
worksheet.write(index, 0, self.array_x[index])
41-
worksheet.write(index, 1, self.array_y[index])
35+
worksheet.write(index, 0, self.array_x[index]) #column 0
36+
worksheet.write(index, 1, self.array_y[index]) #column 1
4237
worksheet.write(index, 2, self.array_sum[index])
43-
4438
workbook.close()
4539

4640
if __name__ == '__main__':
4741
file_management = FileManagement()
4842
file_management.read_text_file()
4943
file_management.save_to_xlsx()
50-
51-
52-
Binary file not shown.
Binary file not shown.
Binary file not shown.

Python tutorial - 19 - Crawl web site data with Scrapy/.idea/Python tutorial - 19 - Crawl web site data with Scrapy.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python tutorial - 19 - Crawl web site data with Scrapy/.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python tutorial - 19 - Crawl web site data with Scrapy/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)