Created
November 3, 2017 02:55
-
-
Save laixintao/666f2af2ed7dc34cf74471c64984e5b2 to your computer and use it in GitHub Desktop.
xlsx to json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""将excel转换成json""" | |
import json | |
import pandas | |
import numpy | |
courts = pandas.read_excel("courts.xlsx") | |
name_mapping = {} | |
for court in courts.iterrows(): | |
stand_name = "" | |
for value in court[1]: | |
if not stand_name: | |
stand_name = value | |
names = name_mapping.setdefault(stand_name, []) | |
if not pandas.isnull(value): | |
names.append(value) | |
print(json.dumps(name_mapping, indent=2, ensure_ascii=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment