We have a script that handles data-import. Now that most of the data is properly sanitized we want to focus on fine-tuning the MYSQL backend. This backend is in some cases to rigidly defined (i.e. strings are longer than the varchar allows ...). Since we have new data on a weekly basis we want to log it weekly so that we can use that log to check the data-source and if necessary modify the backend.
For this the importscript needs to be modified slightly:
None-1366 MYSQL-warnings need to be suppressed and pretty printed (OK)
All MYSQL-warnings need to be written to a log file (OK)
Hide the default error notice on import, because this floods the terminal with 1366 warnings. (NOT ok)
The code I have now is (This is only a small part out of a larger script):
into_file_operation = "LOAD DATA LOCAL INFILE '%s/%s.csv' INTO TABLE %s FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '' LINES TERMINATED BY '\\r';" %(folder, name, name)
#warnings.filterwarnings("ignore")
cursor.execute(into_file_operation)
conn.commit()
conn.close
warnings = conn.show_warnings()
for w in warnings:
if w[1] != 1366:
pprint(w, width=100, depth=2) ##PPRINT non-1366 errors
else:
print(str(w[1]), end='\r') #this can be turned into pass later.
errorfile.write(str(w)+"\n") #write ALL to file
errorfile.flush()
errorfile.write("\n")
errorfile.write("********* DONE TABLE **********")
errorfile.write("\n")
errorfile.flush()
This meets the first two demands, yet it still outputs the very long warnings to the console - which we want to get rid off:
C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\cursors.py:166: Warning: (1366, "Incorrect integer value: '' for column 'y1' at row 126") result = self._query(query)
and errors like 1265 can be shown, but need to be pretty printed. With the current code, these get printed twice (first time, the long warning, second time a formatted warning using PrettyPrint)
I think that my next step would be to do something with the STDOUT, yet whatever I tried, I keep ending up with an empty database. I've also tried to use the filter with the ignore parameter, yet then I don't get any warnings at all - which defeats the purpose of having the log.
The binary I am debugging in gdb first asks me for a id first and then if the id is valid asks for a second input.
gef➤ run
Agent ID : 48093572 //This is the first input which the user has to enter
Login Validated
Main Menu:
1. Extraction Points
2. Request Extraction
3. Submit Report
0. Exit
Enter selection: // This is the second input the user has to enter
How can I pass both the inputs from a file using the '<' operator. If there was a single input I could have done it as
gef➤ run < input.txt
But the approach above is not working for multiple inputs.
*Note:- gef is an addon for gdb
In case you haven't found the solution, or anyone else needs this bit of information, this worked for me:
gdb$ r < <(cat 1_intest.txt 2_intest.txt)
Each input gets passed to the program by cating the corresponding file's content.
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
You've set a rather tall order for TI-Basic to fill. user3932000 is correct; there is no built in function to create an input form of the type you request.
However, there is nothing stopping you from creating an interactive interface yourself. Creating it from scratch will be a time consuming and, it will consume a significant amount of memory on your calculator. There is no boilerplate code you plug your variables into to get the results you want, but you might have some luck modeling it after this quadratic solver I wrote.
ClrHome
a+bi
Output(1,1," QUADRATIC
Output(2,1," AX²+BX+C
Output(3,1,"ZEROS:
Output(6,1,"A=
Output(7,1,"B=
Output(8,1,"C=
DelVar YDelVar D
" →Str1
While Y≠105
getKey→Y
If Ans
Then
Output(X,4,Str1
Output(3,7,Str1+Str1+Str1+"
End
X+(Ans=34)-(Ans=25
If Ans<6:8
If Ans>8:6
Ans→X
Output(Ans,16,"◄
D(Y≠45→D
If Y=25 or Y=34
sum({A,B,C}(X={6,7,8→D
If Y=104:⁻D→D
10not(Y)+Y(102≠Y)-13int(Y/13(2>abs(5-abs(5-abs(Y-83
If Ans≤9
D10+Ans-2Ans(D<0→D
If X=6:D→A
If X=7:D→B
If X=8:D→C
If A
Then
2ˉ¹Aˉ¹(⁻B+{1,⁻1}√(B²-4AC
Else
If B
Then
⁻C/B
Else
If C
Then
"No Zeros
Else
"All Numbers
End
End
End
Output(3,7,Ans
Output(6,3,A
Output(7,3,B
Output(8,3,C
End
ClrHome
Ans
Here's a GIF of what it does for you.
With a little more work. This code could be used on the Graph screen instead of the home screen, giving more option in terms of layout and design.
In the TI-BASIC programming language (Specifically TI-84+), how do you create input forms, such as the ones included in the default apps on the TI-84+.
There are many ways to ask for input in your program:
Prompt: Asks for input and stores it in a variable. For example, Prompt A. Simplest way to ask for input, but not very visually appealing.
Input: Similar to the Prompt command, except that now you can include text within the input. For example, Input "What is your name?",A.
Menu(: Multiple choice input, and each choice is connected to a Lbl marker somewhere else in the script. Much like the error screen with the quit/goto choices that you've probably seen. For example, Menu("Are you a boy or a girl?","Boy",B,"Girl",G).
getKey: Checks if a certain key is pressed, and will output True (1) if that key is pressed. For example, getKey 105. See here for which numbers each key corresponds to.
The image included here shows an example of what I'm trying to create: A menu that you can scroll through and input multiple variables freely before executing a function http://imgur.com/ulthDRV
I'm afraid that's not possible in programs. You can either put in multiple inputs, or you might be interested in looking into making apps instead.
Additionally, is it possible to make this menu dynamically-updating as variables are entered?
If you're talking about the text on top of the screenshot, yes you can; just put a Disp command or something after each line of Input, so that it continuously overwrites the text above with new text after you input a variable.
In RPGLE I'm try to get the SFLSCROLL from a DSPF with multiple formats displaying. I used a read of the SFLCTL to get the SFLSCROLL but the screen is waiting for a response.
How can get it to return to the program without the wait?
You can't.
From the manual: 'You use this field-level keyword in the subfile-control record format to return the relative record number of the subfile record that is at the top of the subfile when control is given back to your program.'
You could use WAITRCD() on CRTDSPF to cause a timeout, but you still need to wait for the timeout to expire.
Thank You I did see that solution but here it was a an order issue on the display.
There is a detail screen on the top of the screen then a subfile on the bottom.
(do not ask why the detail was not in the subfile control I think they had planned for multiple details in the header area)
They were doing a write of the sflctl then exfmt for the detail.
That was not giving me the SFLRRN to check new prompt in the subfile.
I changed it to do a write of the detail exfmt of the sflctl read of detail and that got all the data for me to process with them only hitting enter once after the display occurred so I could check the prompt in the subflctl:
C write dtl2
C exfmt sflctl1
C read dtl2
This is my Output using system.out.println which i got in Linux Server .
The problem is taht , i am not able to view the output from serial number 1 , as the below occupies the entire screen .
please tell me how can i scroll to top ??
341:allitems: tq_relation
342:allitems: tr_num
343:allitems: trader_id
344:allitems: tradetick
345:allitems: trading_state
346:allitems: treas_shrs
347:allitems: treas_stk
348:allitems: treasury_yield
349:allitems: trend
350:allitems: uask_quote
351:allitems: uask_quote_date
352:allitems: ubid_quote
353:allitems: ubid_quote_date
354:allitems: under_cusip
355:allitems: undersymbol
356:allitems: unique_symbol
357:allitems: unit_measure
358:allitems: unpriced
359:allitems: unsolicited
360:allitems: valoren
361:allitems: value_pr_shortinterest
362:allitems: value_shortinterest
363:allitems: vega
364:allitems: vl
365:allitems: vol
366:allitems: volatility12
367:allitems: vwap
368:allitems: wanted_off_bid_ind
369:allitems: wk52hi
370:allitems: wk52hidate
371:allitems: wk52hidate_t
372:allitems: wk52lo
373:allitems: wk52lodate
374:allitems: wk52lodate_t
375:allitems: wkinprog
376:allitems: xchg
377:allitems: xdate
378:allitems: xday
379:allitems: xmonth
380:allitems: xyear
381:allitems: yield
The Power of Linux is that you are able to redirect in and output of certain commands to other commands as using the output of program 1 as input for program 2. This can be archived by using:
program1|program2
and more specific you could use a pager like less or more. With the less command you are able to scroll back and forth and search specific patterns in the output. The more command displays the output page wise. The next page of the file is displayed by hitting the enter key. For your purpose all you have to to is using.
myprogram|less
or
myprogram|more
whatever you prefer. The other approach is to redirect the output to a file. You can do this with the Redirection Operator > and
myprogramm > log.txt
will log the output log.txt.
There is even a third method using the script command. When you are typing
script log.txt
at least in bash this would open a subshell and every input and output that is will get logged to log.txt. You can close and afterwards access the logile by using exit. In the last two cases you can view the log.txt file with you favorite text editor or pager.
You can redirect the output of you program to a text file:
$ ./myprogram >output.txt
Then view the text file with any text editor you like.
You can also pipe the result to the more command:
$ ./myprogram | more