我正在编写一个程序,以读取和存储给定的电子邮件ID,并将其对应的名字存储在数据结构中。
我在获取电子邮件ID并搜索其对应的名字后尝试运行一个for循环,但是它不起作用
这是我到目前为止尝试过的:
obj=function_which_reads_email
for i in obj:
with open('..\Project2\newcsv.csv') as file:
data = csv.reader(file)
df.loc=[df['Email']==i,'First_name']
总是收到相同的错误:
json.decoder.JSONDecodeError:第...行的无效控制字符...
答案 0 :(得分:0)
import pandas as pd
#First read csv pd.read_csv()
df = pd.DataFrame([['a',2],['b',4]],columns=['col1','col2'])
#value : col1 and key = col2
dictionary = {}
for i in range(len(df)):
dictionary[df.iloc[i][0]] = df.iloc[i][1]
答案 1 :(得分:0)
谢谢,但是我找到了解决方案。我将文件路径存储在.json文件中,然后读取文件路径,将其打开,然后在字典中返回相应电子邮件ID的名字。
d = {}#创建字典
Dim cnnPointer As ADODB.Connection
cnnPointer.ConnectionString = "DRIVER={Oracle in 112};" _
& "DBQ=" & Me.txtMiljoe.Text & ";" _
& "UID=" & Me.txtUser.Text & ";" _
& "PWD=" & Me.txtPassword.Text & ";"