pandas中的read_csv文件在一列中读取整个csv文件

时间:2017-07-10 12:07:38

标签: csv pandas

我想在pandas中读取csvfile。我用过函数:

ace = pd.read_csv('C:\\Users\\C313586\\Desktop\\Daniil\\Daniil\\ACE.csv',sep = '\t')

作为输出,我得到了这个:

a)第一行(应该是标题)

_AdjustedNetWorthToTotalCapitalEmployed _Ebit _StTradeRec _StTradePay _OrdinaryCf _CfWorkingC _InvestingAc _OwnerAc _FinancingAc _ProdValueGrowth _NetFinancialDebtTotalAdjustedCapitalEmployed_BanksAndOtherInterestBearingLiabilitiesTotalEquityAndLiabilities _NFDEbitda _DepreciationAndAmortizationProductionValue _NumberOfDays _NumberOfDays360

#other rows separated by tab
0   5390\t0000000000000125\t0\t2013-12-31\t2013\tF...
1   5390\t0000000000000306\t0\t2015-12-31\t2015\tF...
2   5390\t00000000000003VG\t0\t2015-12-31\t2015\tF...
3   5390\t0000000000000405\t0\t2016-12-31\t2016\tF...
4   5390\t00000000000007VG\t0\t2013-12-31\t2013\tF...
5   5390\t0000000000000917\t0\t2015-12-31\t2015\tF...
6   5390\t00000000000009VG\t0\t2016-12-31\t2016\tF...
7   5390\t0000000000001052\t0\t2015-12-31\t2015\tF...
8   5390\t00000000000010SG\t0\t2015-12-31\t2015\tF...

你知道为什么会这样吗?我该如何解决?

1 个答案:

答案 0 :(得分:2)

您应该使用参数sep=r'\t'(注意额外的r)。这将使pandas搜索确切的字符串\tr代表raw)