Jump to content

parsing and printing a line


inov8iv
 Share

Recommended Posts

I have to parse an excel file where I grab particular variables, then have to parse them out into "filewriteline" but I have to have certain values left justified, others right justified. Each character below describes a different value, the _ are spaces between values because of them being right or left justified. I remember from vbasic, you could have values write at particular line spaces like value B starts on space 2, F starts on space 39, I starts on space 79.

The problem arises in the fact that D may be 8 or 9 spaces wide, E may be 8 - 15 characters wide, same inconsistencies with F and G.

ABBCCCCCCCCCDDDDDDDDD________EEEEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

Any help is greatly appreciated,

inov8iv

Link to comment
Share on other sites

Look at StringFormat

I may have miss read your question. Look at StringStripWS($string, 1+2+4) to end up with only one space between each value. Then you can use StringSplit($string, " ") split and reassemble as required.

Edited by picaxe
Link to comment
Share on other sites

I have to parse an excel file where I grab particular variables, then have to parse them out into "filewriteline" but I have to have certain values left justified, others right justified. Each character below describes a different value, the _ are spaces between values because of them being right or left justified. I remember from vbasic, you could have values write at particular line spaces like value B starts on space 2, F starts on space 39, I starts on space 79.

The problem arises in the fact that D may be 8 or 9 spaces wide, E may be 8 - 15 characters wide, same inconsistencies with F and G.

ABBCCCCCCCCCDDDDDDDDD________EEEEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

Any help is greatly appreciated,

inov8iv

I think you are talking about the job that StringFormat does in AutoIt. Eg

msgbox(0,"cat and dog",StringFormat("%10s; %-10s;%10s%.2s","cat","dog","","elephants") )
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I have not found a way to do it with stringformat.

The problem arises in the fact that D may be 8 or 9 spaces wide, E may be 8 - 15 characters wide, same inconsistencies with F and G.

ABBCCCCCCCCCDDDDDDDDD________EEEEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDD____________EEEEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDDD____________EEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDDDDD__________EEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDDDDD________EEEEEEEEEEFFFFFF_________GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDDDD__________EEEEEEEEEFFFFF__________GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDD___________EEEEEEEEEEFFFFFF_________GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

ABBCCCCCCCCCDDDDDDDDD________EEEEEEEEEEFFFFFFFF_______GGGGGGGGGGGGGGGGGGGGHH__IJJJJJJJJJJJJJJJ

Like I mentioned before the problem arises in the inconsistent lengths of the data.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...