Thanks a million both of you - sadly I can't get it onto a Unix box - awk was my first thought (well grep, then awk actually) some of these young lads here haven't even heard of it!
Eek - many thanks the flow control logic was my "missing link" which you have kindly and generously supplied - thanks again.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "VBS or similar script to extract data from a huge file and rearrange it"
Collapse
-
VBS should be fine for that.
Create 2 file objects and open both of them (1 reads in the current file, 2 saves the old file)
then create a string that you can slurp data into until you reach the end of that payee at which point you can save the line to the second file.
The code below does most of what you want its old code tho and you will need to add logic to identify if its a new payee line.
Code:dim payee If objFSO.fileExists( "c:\temp\a.txt" ) Then 'Open a file for reading Set oInStream = objFSO.OpenTextfile( "c:\temp\a.txt", Forreading, False ) set oOutStream =fs.CreateTextFile("c:\test.txt",true) lcount=0 Do Until oInStream.AtEndOfStream Line = oInStream.readLine // some validation logic. // add logic to check line to see if its a new new payee record //if new payee save string to second file oOutStream .WriteLine(payee) payee="" end if payee=payee & "/t"&Line Loop oInStream.Close Set oInStream = Nothing oOutStream.WriteLine(payee) oOutStream.Close Set oOuStream=Nothing end if
Leave a comment:
-
Can you get it on a Unix box and awk it?Originally posted by Peoplesoft bloke View PostI have a huge file (P14 for HMRC since you ask) that is in a daft HMRC format - it has a line that identifies the payee, followed by a variable number of lines of data. Each monetary value data item is on a single line, with a single code to identify it on the previous line. What I need to do is rearrange this so I get a row per EE with a column (fixed length or value separated - it doesn't matter).
I've been trying to write a .vbs script to do this (mainly by using Google to try and find similar code). Why vb? - The file has 1,079,198 rows and is therefore not really a candidate for excel - I don't have (and can't get) access and the data can't leave the premises (otherwise I could download some fancy freeware), but my programming skills are pretty meagre to say the least.
The only other viable tool I have access to is an oldish version of ultra edit (too old for scripting)
Any tips, links to sites would be greatly appreciated - bonus points awarded for "use excel, access, take file off site etc etc"
Leave a comment:
-
VBS or similar script to extract data from a huge file and rearrange it
I have a huge file (P14 for HMRC since you ask) that is in a daft HMRC format - it has a line that identifies the payee, followed by a variable number of lines of data. Each monetary value data item is on a single line, with a single code to identify it on the previous line. What I need to do is rearrange this so I get a row per EE with a column (fixed length or value separated - it doesn't matter).
I've been trying to write a .vbs script to do this (mainly by using Google to try and find similar code). Why vb? - The file has 1,079,198 rows and is therefore not really a candidate for excel - I don't have (and can't get) access and the data can't leave the premises (otherwise I could download some fancy freeware), but my programming skills are pretty meagre to say the least.
The only other viable tool I have access to is an oldish version of ultra edit (too old for scripting)
Any tips, links to sites would be greatly appreciated - bonus points awarded for "use excel, access, take file off site etc etc"Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Data Kraken v Torry Harris: 5 lessons for software developer contractors Today 06:09
- Loan Recall Case Study: Amanda Yesterday 06:00
- How IR35 inflated an £8.5bn consultancy bill — and tests Burnham at the Budget Aug 28 07:47
- Autumn Budget 2026: FCSA’s 5 contractor asks of John Healey Aug 27 04:15
- Andy Burnham's Zoom gripe doesn’t apply to IT contractors, say recruiters Aug 26 03:41
- Check your Loan Recall paperwork for the Isle of Man: it could matter Aug 25 03:27
- Budget 2026: Contractor advisers ask for ‘IR35 reset’ Aug 24 04:57
- Why might an umbrella company fail to pay its total tax bill to HMRC? Aug 18 06:08
- Contractors, here are the late payment fixes that the Lords just turned down Aug 17 08:03
- How will HMRC's Direct Debit plan affect contractors paying VAT and PAYE? Aug 13 23:54

Leave a comment: