當此寫入一個CSV文件,它的寫每個字母變成自己的細胞。有關如何解決這個問題的任何想法?寫作到CSV文件
我想寫「名」自身的細胞。
謝謝!
import json
import csv
from unidecode import unidecode
def main():
csv_writer = open_csv() #returns the functionality to write to a csv
str_data = []
with open('location') as f:
for line in f:
str_data.append(json.loads(line))
data = str_data[0]
for item in data['contacts']:
linkedin_name = unidecode(name(item))
write_to_csv(csv_writer, linkedin_name)
def name(item):
name = item['name']
return name
def open_csv():
final_csv = open('test.csv', 'wb')
csv.writer = csv.writer(final_csv)
return csv.writer
def write_to_csv(csv_writer, linkedin_name):
csv_writer.writerow(linkedin_name)
if __name__ == '__main__':
main()
奇怪代碼.... –
的該推移線'csv.writer = csv.writer(final_csv)'是適合萬聖節我想) –