我试图手动从网站上抓取表格信息,以便导入Drupal网站。
数据格式如下:
Opening Balances of Banks/Discount Houses 76991.16
Rediscounted Bills 0
Standing Lending Facility (Net) 0
Standing Deposit Facility (Net) 522078.9
Repo 0
Reverse Repo 0
OMO Sales/Under-Writing by MMDs 0
OMO Repayment 0
将其粘贴到电子表格中,我可以创建一个CSV文件以导入Drupal。 CSV生成如下:
Opening Balances of Banks/Discount Houses,76991.16
,
Rediscounted Bills,0
,
Standing Lending Facility (Net),0
,
Standing Deposit Facility (Net),522078.9
,
Repo,0
,
Reverse Repo,0
,
OMO Sales/Under-Writing by MMDs,0
,
OMO Repayment,0
我的问题是CSV错了。第一列中的数据应代表CSV的标题,这意味着它们应列在CSV的第一行而不是左侧。接下来的行应该是要导入的数据序列,作为标题中项目的出现。
任何人都可以请教我如何以正确的顺序生成CSV以解决我的问题?
要导入数百行数据,因此手动方法不可行。
更新 两个完整的记录:
Date Financial Data As At 5/8/2014
Opening Balances of Banks/Discount Houses 76991.16
Rediscounted Bills 0
Standing Lending Facility (Net) 0
Standing Deposit Facility (Net) 522078.9
Repo 0
Reverse Repo 0
OMO Sales/Under-Writing by MMDs 0
OMO Repayment 0
Primary Market Sales (e.g NTBs, FGN Bonds) 0
Primary Market Repayment 0
CRR (Debit/Credit) 0
Net Foreign Exchange Auction (WDAS) 0
Statutory Allocations (FAAC, VAT,etc) 0
Joint Venture Cash Call Payment 0
Net Clearing (Lagos/Abuja) 0
NDIC Premium (Debit/Credit) 0
Other Major (Debit/Credit) 0
Date Financial Data As At 5/7/2014
Opening Balances of Banks/Discount Houses 98357.49
Rediscounted Bills 0
Standing Lending Facility (Net) 475
Standing Deposit Facility (Net) 483157.7
Repo 0
Reverse Repo 0
OMO Sales/Under-Writing by MMDs 0
OMO Repayment 237451.43
Primary Market Sales (e.g NTBs, FGN Bonds) 157177.87
Primary Market Repayment 157057.31
CRR (Debit/Credit) 0
Net Foreign Exchange Auction (WDAS) 0
Statutory Allocations (FAAC, VAT,etc) 0
Joint Venture Cash Call Payment 0
Net Clearing (Lagos/Abuja) 0
NDIC Premium (Debit/Credit) 0
Other Major (Debit/Credit) 0
答案 0 :(得分:0)
CSV似乎很容易,但事实并非如此。想象一下,如果在第一列的中间,你有一个逗号,并且爆炸。
现在想象两个逗号。
: - )
我不知道你将使用什么语言来处理这个问题(也许是php),但我认为你必须写一些程序
那是因为HTML清楚地说明了细胞内部的内容和不清楚的内容。虽然手动复制和粘贴会得到内容,但是没有格式化,你最终会遇到角落问题。
对于PHP中的优秀CSV库,请查看https://stackoverflow.com/questions/3087287/is-there-a-popular-and-or-robust-php-csv-library
答案 1 :(得分:0)
TextDistil会为您完成此操作。 (披露 - 我是作者)。假设您要生成多行,即您描述的8列中的每一列,最简单的方法是:
请注意,在将模式粘贴到TextDistil中时不应包含引号
8分之5/ 2014,76991.16,0,0,522078.9,0,0,0,0,0,0,0,0,0,0,0,0,0 5/7 / 2014,98357.49,0,475,483157.7,0,0,0,237451.43,157177.87,157057.31,0,0,0,0,0,0,0
您可能会发现所有'视图很有用 - 它允许您查看最终输出以及要添加的配方的输入和输出。