我有一个csv文件要转换。当前csv文件中的数据如下所示
115776 1142 1523 20197 20394 3421 1284 9572 19682
但我希望它看起来像这样
^{pr2}$。。。。。在
有什么办法吗?在
我现在写了一个函数来获取它,它是这样得到的
for row in read_csv(testfile, "Recipes_RecipeId Recipes_Ingredients_0_IngredientID Recipes_Ingredients_1_IngredientID Recipes_Ingredients_2_IngredientID Recipes_Ingredients_3_IngredientID Recipes_Ingredients_4_IngredientID Recipes_Ingredients_5_IngredientID Recipes_Ingredients_6_IngredientID Recipes_Ingredients_7_IngredientID Recipes_Ingredients_8_IngredientID".split()):
with open('recipeIngredientID.csv', 'a') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(row)
有没有更好的方法把它打印出来我想要它?在
将csv读入python列表:Python import csv to list
然后简单地循环列表,重复第一个索引:
相关问题 更多 >
编程相关推荐