AutoHotkey Community

It is currently May 26th, 2012, 10:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Parser
PostPosted: October 22nd, 2009, 4:49 am 
I need help making a parser from a CSV file.

For instance.

This is the data that I would want to parse out.
12,312,123,,,345

The Parser would do something like this.
Row A = 12
Row B = 312
Row C = 123
Row D = N/A
Row E = N/A
Row F = 345

Thanks.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 4:51 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Check the manual: FileRead / Loop / File-reading Loop

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 5:19 am 
My mistake. I don't actually want to READ a file. I want to copy and paste data that is delimited by commas and parse it out. Like if I copied the text

12,312,123,,,345

into a box. It would at that time parser it out or store it in a hotkey.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 5:30 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
It's all in the manual.
- Clipboard
- Loop (parse)
- Send

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 5:58 am 
Here's a simple example to study along with links from MasterFocus:
Code:
letters = ABCDEFGHIJKLMNOPQRSTUMWXYZ
StringSplit, letter, letters
Loop, Parse, ClipBoard, `,
   data .= "Row " letter%A_Index% " = " (A_LoopField ? A_LoopField : "N/A") "`n"
MsgBox, %data%


Report this post
Top
  
Reply with quote  
 Post subject: Thanks
PostPosted: October 25th, 2009, 1:05 am 
I appreciate the practice code. One last question on it. I haven't added much to it. But here I go.

This is what I have
Code:
letters = ABCDEFGHIJKLMNOPQRSTUMWXYZ
StringSplit, letter, letters
Loop, Parse, ClipBoard, `,
   data .= "Row " letter%A_Index% " = " (A_LoopField ? A_LoopField : "N/A") "`n"
Sendinput %data%


When I copy something like this:

Quote:
STOP,00270103,0x0001003B09ECC1C4,1991967974


This is the result I get when I type test1.
Quote:
Row A = STOP
Row B = 00270103
Row C = 0x0001003B09ECC1C4
Row D = 1991967974


I want to do 2 things to this.

One I want to alter row's to different names like

Quote:
Timer = STOP
Switch = 00270103
Hex = 0x0001003B09ECC1C4
Number = 1991967974


And second I want to only display certain rows that I want.
Like
Quote:
Timer = STOP
Hex = 0x0001003B09ECC1C4


Any help is appreciated. Thanks.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 11:54 am 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
Code:
Lables = Timer,Switch,Hex,Number
StringSplit,lable,lables,`,
Loop, Parse, ClipBoard, `,
   data .=  lable%A_Index% " = " (A_LoopField ? A_LoopField : "N/A") "`n"
Msgbox, % data


With input...

Code:
Lables = Timer,Switch,Hex,Number
StringSplit,lable,lables,`,
Loop, Parse, ClipBoard, `,
   data .=  lable%A_Index% " = " (A_LoopField ? A_LoopField : "N/A") "`n"
SendInput, % data

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, JSLover, Leef_me, patgenn123, rbrtryn, XstatyK and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group