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
- How key for IR35 will Control be in 2026/27? Yesterday 07:13
- What does the non-compete clause consultation mean for contractors? Feb 19 07:59
- To escalate or wait? With late payment, even month two is too late Feb 18 07:26
- Signs of IT contractor jobs uplift softened in January 2026 Feb 17 07:37
- ‘Make Work Pay…’ heralds a new era for umbrella company compliance Feb 16 08:23
- Should a new limited company not making much money pay a salary/dividend? Feb 13 08:43
- Blocking the 2025 Loan Charge settlement opportunity from being a genuine opportunity is… HMRC Feb 12 07:41
- How a buyer’s market in UK property for 2026 is contractors’ double-edge sword Feb 11 07:12
- Why PAYE overcharging by HMRC is every contractor’s problem Feb 10 06:26
- Government unveils ‘Umbrella Company Regulations consultation’ Feb 9 05:55

Leave a comment: