Python csv文件写在不同的列中

时间:2018-03-05 14:50:29

标签: python csv

我试图读取一个csv文件,并使用Python创建一个新的cvs文件,其中包含旧cvs文件的内容。我的问题是,所有的声明都保存在第一列,我无法找到一种方法来保存不同列中的信息。这是我的代码:

import csv
from itertools import zip_longest

fieldnamesOrdered = ['First Name', 'Last Name' , 'Email', 'Phone Number', 
'Street Address', 'City', 'State', 'HubSpot Owner', 'Lifecyle Stage', 'Lead 
 Status', 'Favorite Color']

listOne = []
listTwo = []

with open('Contac.csv', 'r', encoding = 'utf-8') as inputFile, 
open('result.csv', 'w', encoding = 'utf-8') as outputFile:

    reader = csv.DictReader(inputFile)
    writer = csv.writer(outputFile, delimiter = 't')
    for row in reader:
        listOne.append(row['First Name'])
        listTwo.append(row['Last Name'])

    dataLists = [listOne, listTwo]
    export_data = zip_longest(*dataLists, fillvalue='')
    writer.writerow(fieldnamesOrdered)
    writer.writerows(export_data)

inputFile.close()
outputFile.close()

非常感谢您的回答

1 个答案:

答案 0 :(得分:1)

java.lang.IllegalArgumentException: org.keycloak.admin.client.resource.RealmsResource referenced from a method is not visible from class loader
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Proxy.java:851) ~[na:na]
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:682) ~[na:na]
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:628) ~[na:na]
    at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:426) ~[na:na]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:327) ~[na:na]
    at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:203) ~[na:na]
    at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:424) ~[na:na]
    at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:999) ~[na:na]
    at org.jboss.resteasy.client.jaxrs.ProxyBuilder.proxy(ProxyBuilder.java:79) ~[resteasy-client-3.1.4.Final.jar!/:3.1.4.Final]
    at org.jboss.resteasy.client.jaxrs.ProxyBuilder.build(ProxyBuilder.java:131) ~[resteasy-client-3.1.4.Final.jar!/:3.1.4.Final]
    at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.proxy(ClientWebTarget.java:93) ~[resteasy-client-3.1.4.Final.jar!/:3.1.4.Final]
    at org.keycloak.admin.client.Keycloak.realms(Keycloak.java:114) ~[keycloak-admin-client-3.4.3.Final.jar!/:3.4.3.Final]
    at org.keycloak.admin.client.Keycloak.realm(Keycloak.java:118) ~[keycloak-admin-client-3.4.3.Final.jar!/:3.4.3.Final]

Aren在第一栏中的那些条目中还散布着奇怪的未经请求的&#39; t&#39;字符?