Created
July 17, 2018 17:53
-
-
Save twosky2000/d8a2bec7eccef03e64ba82733da8b97f to your computer and use it in GitHub Desktop.
Example of a Converter from EFS(ETS4) to yaml
This file contains 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
mport csv | |
import yaml | |
from collections import OrderedDict | |
with open("test.csv", "r", encoding="ISO-8859-1") as csvfile: | |
reader = csv.reader(csvfile, delimiter='\t') | |
config = yaml.load(""" | |
#test | |
ETS_Name: "bla" | |
""") | |
for indexR, row in enumerate(reader): | |
if (indexR == 0): | |
#print("Title: "+ str(row[0])) | |
#config.append({"ETS_Name":row[0]}) | |
config["ETS_Name"]= row[0] | |
else: | |
print(indexR) | |
for indexC, colum in enumerate(row): | |
if (colum != ""): | |
config[indexR ][str(colum)]= "test" | |
#config["ETS_Name"][indexR+1]= tmpcol | |
print(config) | |
with open("test.yaml","w") as yaml_file: | |
yaml.dump(config,yaml_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment