下面有三个表。我想通过合同将记录插入到CSV文件中。有三个表,具有不同的列数。Contracts有5列,Member有3列,QTY有2列。我必须按约定插入记录,以便CSV文件中的输出看起来像下面的输出。 select * from #contracts_master where ContractNumber='PCCCA7859'
select * from #Member_full where ContractNumber='PCCCA7859'
select * from #QTY where ContractNumber='PCCCA7859
我有一个csv文件,其中包含以下列:
Email | Date | Location
我很想把它直接扔到数据库表中。问题是文件中的位置值是字符串--例如:“波士顿”。要插入的表具有整数属性LocationId。
因此,在我的数据流中,我需要执行一个数据库查询,以获得与位置相对应的LocationId。例:
SELECT Id as LocationId FROM Locations WHERE Name = { location string from current csv row }
并将其添加到当前列中,将其设置为新值"LocationId“。
我不知道怎么做--我尝试了查找,但
我有CSV文件,其中一个列中存储了一些链接。我只想阅读链接并将它们打印出来。我尝试使用以下代码,但输出为none。
import csv
filename ='abc.csv'
with open(filename,'rb') as f:
reader = csv.reader(f)
for row in reader:
for item in row:
if item.startswith('http'):
print(item)