I want to select a sub-string obtained from a text file and analyze it.
Text file:
NADSU 78000mc0cl0Css
NADBY 7808810008659
PAT 1 21D 089
I need to read and later analyze line by line of a .txt file after that I would like to verify by means of an if or case cycle that the paramentros could be fulfilled. I clarify the txt file has about 300 lines
The first three characters must be letters with a specific format, the next is usually the 4 character or 5 that has a number depends on that number means something and the last is the purchase order number or the amount or type of wrap.
This is a generalized idea I am only giving the minimum to understand.
Example of two real cases of the line to analyze:
NADBY 7808810008659
The letters NAD
is the Purchase Order BY
is the Supplier and the remainder is the Purchase Order Number .
PAT 1 21D 089
PAT
means Type of payment , the first number is the Type of payment where: if% is 1
Type of payment is counted , if 2
is Credit . The middle 21d
is the amount of days to issue clearance and the 089
is the number of days to pay.
NADSU 78000mc0cl0Css
The letters NAD
are for Purchase Order and BY
is Buyer ; Css
equals boxes but can be ss
, which is equivalent to mini-jacks .
<% fileopen ('nombre_doc.txt',r) do |fichero1| %>
<% fileopen ('copianombre_doc.txt',w) do |fichero2| %>
<% while linea= fichero1.gets %>
<% fichero1=gsub(/\s+/,'') %>