✅ Reading Text in File at Position x
Hello. I would have to read the text of job_offer_data, starting with target and ending with trailer_place, from the text field.
Since the text can always be somewhere different in my text field, the method with a fixed line number doesn't work.
Can someone help me with that? With Contains I get up to the line job_offer_data but it's not clear to me how I can output the 13 lines from then on
14 Replies
Is this a school assignment or something?
its for me, not for school
to old for school ^^
You have to know the file position to seek to, you can't really get position from line number
Structured formats exist, like json, yaml, parquet, etc
Some of them can be read "forward only", or a bit at a time
ok, i read the file with File.ReadLines
Iirc ReadLines is an enumerable?
You could try to get the line number with a for loop and then read out 13 lines from there?
Yeah, something like that could work
But it's fragile
It'll work until the format changed
The format of this text block always remains the same, only the position changes
So really rather than 13 lines to want to read to your next marker
I'll test it tomorrow and if I get stuck, I'll let you know
kk
if the fields are unique you can treat them like kvp's ( key: value pairs ) and store them in a dictionary and read them to your hearts content
something like....
you have duplicate keys though
so then you're reading like a for loop like you suggested.
a sollution could be:
read complete file split it into an array (on the line)
Go through it with a for next or use a ling with contains
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Ok, i found an solution!
it read the lines at startingline and read 'readlines' from the file and take it to an List string