I am attempting to manually scrape tabular information from a website for importing into a Drupal site.
The data is of the following format:
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
Pasting that into a spreadsheet, I can create a CSV file for importing into Drupal. The CSV generates as follows:
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
My problem is the CSV is wrong. The data in the first column should represent the headers of the CSV which means they should be listed on the first line of the CSV and not on the left. The followed lines should then be the sequence of data to be imported as occurrences of items in the header.
How can I generate a CSV file in the correct order which will solve my problem?
There are hundred of lines of data to import so a manual approach is not feasible.
UPDATE: Two full records:
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
TextDistil will do this for you. (Disclosure - I'm the author). Assuming that you want to generate multiple rows, each of the 8 columns you've described, the easiest way to do it is:
Note that you should not include the quotes when pasting patterns into TextDistil
5/8/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
You may find that the 'all' view is useful - it allows you to see both the final output and the input and output of the recipe you are adding.