[Solved] Read in a csv file as a variable in python

Here a bare code that should do what you are asking: import tkinter as tk from tkinter import filedialog from tkinter import simpledialog import pandas as pd root = tk.Tk() root.withdraw() path = filedialog.askopenfilename(parent=root, filetypes=[(“CSV Files”,”.csv”)]) col1 = simpledialog.askstring(“Input”, “Column 1″, parent=root, initialvalue=”col1”) col2 = simpledialog.askstring(“Input”, “Column 2″, parent=root, initialvalue=”col2”) df = pd.read_csv(path, usecols=[col1, col2]) … Read more

[Solved] Matrix indexing combinations but one per row

Itertools has it: import itertools x = [ [1,2,3],[4,5,6],[7,8,9]] for y in list(itertools.product(*x)): print y it gives you: (1, 4, 7) (1, 4, 8) (1, 4, 9) (1, 5, 7) (1, 5, 8) (1, 5, 9) (1, 6, 7) … (3, 6, 9) 3 solved Matrix indexing combinations but one per row

[Solved] How can I save a variable in my function to use it again?

Onk_r has the right answer: static variables within the body ({}) of a function ‘stick around’. Specifically, the expression which initializes the value of a static variable within a function body is executed only once, so the next time you call that function whatever value it had last will remain. However, that won’t solve your … Read more

[Solved] PDF Type Detection [closed]

You can convert the PDF to HTML format using PDFMiner. Then you can use beautifulsoup to find if it contains only <img> tag then it’s totally a scanned PDF, otherwise, if any text data found then it is electronic. Moreover, you can decide this based on the percentage of text extracted. 1 solved PDF Type … Read more

[Solved] How to benchmark code to see which runs faster

To benchmark code, you can use microtime() http://php.net/manual/en/function.microtime.php <?php echo ‘modify: ‘; $time = microtime(1); for ($x = 0; $x < 10000; $x++) { $datetime = new DateTime(‘2013-01-29’); $datetime->modify(‘+1 day’); } echo $datetime->format(‘Y-m-d H:i:s’); $end = microtime(1); $time = $end – $time; echo $time . “\n”; echo ‘interval: ‘; $time = microtime(1); for ($x = … Read more

[Solved] “Unfortunately MyApp has stopped” when I Press A Button [duplicate]

You have not casted the image buttons correctly. Use this in onCreate() baslat = (ImageButton)findViewById(R.id.baslatButonu); ayarlar =(ImageButton) findViewById(R.id.ayarlarButonu); And Declare this activity in manifest <activity android:name=”.Ayarlar”> From the logcat **java.lang.RuntimeException: Font asset not found fonts/Bariol_Regular.otf** Add this font file also Bariol_Regular.otf Check this link please How to use custom font in Android Studio 9 solved … Read more

[Solved] How to add xml child to first index of an array using php

There are a lot if issues with the code you have, so I’ve just written something new… $result = [“<mo>+</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi><mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac>”, “<mo>+</mo><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn>”, “<mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn>”, “<mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi>” ]; $arr_result=[]; for ($i=0; $i < count($result) ; $i++) { if (substr($result[$i],0,4)!=”<mo>”) { $arr_result[]= “<mo>+</mo>”.$result[$i]; } else { $arr_result[]= $result[$i]; } } print_r($arr_result); This just goes through each line at a time, … Read more