Sign in to follow this  
Followers 0
inov8iv

parsing and printing a line

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I got it, martin you got me on the right path, I just need to stringformat EACH STRING.

Thanks for the guidance....:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0