How to select specific data from text file in VB? - vb.net

I am making an Arduino weather station and I am outputting the data to a simple text file. But I want to make a like a year log of the highest and lowest temps. So my question is how can I select only the data between some symbols and then use it in VISUAL BASIC...For example my text file contains this string:"[29.11.2015 AT: 19:19:43] MR t. C:| 22.18 |Out t. C:| 7.36 |Aqu. H20 t. C:| 23.12 |Light(MR):| 1.63 | Door in MR:CLOSED!" and as you can see all the data is surrounded by these "|", can I make vb to get only this data and then compare it to previous one?

Take a look at TextFieldParser. Your delimiter will be the "|".

Related

Remove decimal separator with output format on real values in Fortran [duplicate]

So I have some code that does essentially this:
REAL, DIMENSION(31) :: month_data
INTEGER :: no_days
no_days = get_no_days()
month_data = [fill array with some values]
WRITE(1000,*) (month_data(d), d=1,no_days)
So I have an array with values for each month, in a loop I fill the array with a certain number of values based on how many days there are in that month, then write out the results into a file.
It took me quite some time to wrap my head around the whole 'write out an array in one go' aspect of WRITE, but this seems to work.
However this way, it writes out the numbers in the array like this (example for January, so 31 values):
0.00000 10.0000 20.0000 30.0000 40.0000 50.0000 60.0000
70.0000 80.0000 90.0000 100.000 110.000 120.000 130.000
140.000 150.000 160.000 170.000 180.000 190.000 200.000
210.000 220.000 230.000 240.000 250.000 260.000 270.000
280.000 290.000 300.000
So it prefixes a lot of spaces (presumably to make columns line up even when there are larger values in the array), and it wraps lines to make it not exceed a certain width (I think 128 chars? not sure).
I don't really mind the extra spaces (although they inflate my file sizes considerably, so it would be nice to fix that too...) but the breaking-up-lines screws up my other tooling. I've tried reading several Fortran manuals, but while some of the mention 'output formatting', I have yet to find one that mentions newlines or columns.
So, how do I control how arrays are written out when using the syntax above in Fortran?
(also, while we're at it, how do I control the nr of decimal digits? I know these are all integer values so I'd like to leave out any decimals all together, but I can't change the data type to INTEGER in my code because of reasons).
You probably want something similar to
WRITE(1000,'(31(F6.0,1X))') (month_data(d), d=1,no_days)
Explanation:
The use of * as the format specification is called list directed I/O: it is easy to code, but you are giving away all control over the format to the processor. In order to control the format you need to provide explicit formatting, via a label to a FORMAT statement or via a character variable.
Use the F edit descriptor for real variables in decimal form. Their syntax is Fw.d, where w is the width of the field and d is the number of decimal places, including the decimal sign. F6.0 therefore means a field of 6 characters of width with no decimal places.
Spaces can be added with the X control edit descriptor.
Repetitions of edit descriptors can be indicated with the number of repetitions before a symbol.
Groups can be created with (...), and they can be repeated if preceded by a number of repetitions.
No more items are printed beyond the last provided variable, even if the format specifies how to print more items than the ones actually provided - so you can ask for 31 repetitions even if for some months you will only print data for 30 or 28 days.
Besides,
New lines could be added with the / control edit descriptor; e.g., if you wanted to print the data with 10 values per row, you could do
WRITE(1000,'(4(10(F6.0,:,1X),/))') (month_data(d), d=1,no_days)
Note the : control edit descriptor in this second example: it indicates that, if there are no more items to print, nothing else should be printed - not even spaces corresponding to control edit descriptors such as X or /. While it could have been used in the previous example, it is more relevant here, in order to ensure that, if no_days is a multiple of 10, there isn't an empty line after the 3 rows of data.
If you want to completely remove the decimal symbol, you would need to rather print the nearest integers using the nint intrinsic and the Iw (integer) descriptor:
WRITE(1000,'(31(I6,1X))') (nint(month_data(d)), d=1,no_days)

How do I define the record structure of ebcdic file?

I have ebcdic file in hdfs I want to load data to spark dataframe, process it and load results as orc files, I found that there is a open source solution which is cobrix cobrix, that allow to get data from ebcdic files, but developer must provide a copybook file which is a schema definition.
A few line of my ebcedic file are presented in the attached image.
I want to get the format of copybook of the ebcdic file, essentially I want to read the vin his length is 17, vin_data the length is 3 and finally vin_val the length is 100.
how to define a copybook file of ebcdic data?
You don't.
A copybook may be used as a record definition (=how the data is stored), it has nothing to do with the encoding of data that may be stored in that.
This leaves the question "How do I define the record structure?"
You'd need the amount of fields, their length and type (it likely is not only USAGE DISPLAY) and then just define it with some fancy names. Ideally you just get the original record definition from the COBOL program writing the file, put that into a copybook if it isn't in one yet, and use that.
Your link has samples that show actually how a copybook looks like, if you struggle on the definition then please edit your question with the copybook you've defined and we may be able to help.
Based on your comment in the question, and looking at the input file, you could start with this.
01 VIN-RECORD.
05 VIN PIC X(17).
05 VIN-COUNT PIC S9(5) COMP-3.
05 VIN-VALUE PIC X(100).
I'm guessing that the second field is COMP-3 based on the six examples all ending with a C byte. This indicates a positive COMP-3 value. A D byte would be a negative COMP-3 value. An F byte would indicate an unsigned COMP-3 value.
The third field is variable length and right padded with spaces.

Vimium: something like "f" for input fields?

In Vimium, is there something like f for input fields? E.g. in a form with 10 input fields, I directly want to jump to the 5th, instead of only gi and tabbing through. Is that possible using Vimium?
Yes, as in many shortcuts in vim you can prefix a command with a number. I.e. to jump to the 5th field you type 5gi.
Other vim style examples (It isn't related to vimium. I included it only to illustrate the approach):
3dd delete 3 lines
2j go up 2 lines
5p paste the buffer 5 times

Replace certain text in lines with each line another file

I have a text file with text of this order;
str/4
<</Contents(100 cups)/(Date)
Colour red
<</Contents(080 bowls)/(Date)
Status used
Pack team
<</Contents(200 John)/(Date)
School house
And another text file with a list of words in the order;
Tree house
Colon format
Same variable
Now the question is, how do I search or match the text between "Contents(" and ")" in each line, ie. 100 cups, 080 bowls, 200 John and replacementreplace it with corresponding lines from my second file? . The final result should look like;
str/4
<</Contents(Tree house)/(Date)
Colour red
<</Contents(Colon format)/(Date)
Status used
Pack team
<</Contents(Same variable)/(Date)
School house

Python: Search Journal.txt for dates and write the corresponding text into a new file for Evernote import

I've been learning Python for a week now and am currently at Exercise 26 (learnpythonthehardway). So I know nothing. I tried searching but couldn't find what I need.
What I need:
I want to write a script that breaks my Journal.txt file into several text files to be able to import them into Evernote. Evernote pulls the title for a note from the first line of the .txt
This is a random example of the date format I used in my Journal.txt
1/13/2013, 09/02/2012, so I'm afraid the date is not consistent. I know about:
if 'blabla' in open('example.txt').read():
but don't know how to use it with a date. Please help me to elicit date corresponding Journal entries from a large file into a new one. This is literally all I got so far:
Journal = open("D:/Australien/Journal.txt", 'r').read()
Consider doing it like recommended here - replacing YOUR_TEXT_HERE with a search pattern for a date, e. g. [0-9]+\/[0-9]+\/[0-9]+.
awk "/[0-9]+\/[0-9]+\/[0-9]+/{n++}{print > n \".txt\" }" a.txt
If you don't have awk installed on your PC, you can fetch it here.