Windows Batch: Set Variables from Text File
Here ya go! Have fun with this one. ( set /p var1= set /p var2= set /p var3= )<Filename.txt Lands you with the same results!
Here ya go! Have fun with this one. ( set /p var1= set /p var2= set /p var3= )<Filename.txt Lands you with the same results!
As others have pointed out, using cat or awk instead of a read-echo loop is a much better way to do this — avoids the whitespace-trimming problem (and a couple of others you haven’t stumbled upon), runs faster, and at least with cat, is simply cleaner code. Nonetheless, I’d like to take a stab at … Read more
f=open(file,”r”) lines=f.readlines() result=[] for x in lines: result.append(x.split(‘ ‘)[1]) f.close() You can do the same using a list comprehension print([x.split(‘ ‘)[1] for x in open(file).readlines()]) Docs on split() string.split(s[, sep[, maxsplit]]) Return a list of the words of the string s. If the optional second argument sep is absent or None, the words are separated … Read more
It is best to use PHP_EOL. This is cross-platform, so it automatically chooses the correct newline character(s) for the platform PHP is currently running on. $stringData = “Floppy Jalopy” . PHP_EOL; PHP Constants
I’m a fan of the Find-In-Files dialog in Notepad++. Bonus: It’s free.
I find this an interesting question, so I made a small console app. I used 3 methods: TStringList Streamreader/StreamWriter Text file All methods are timed and repeated 100 times with a text file of 10kb in size and a text file 1Mb in size. Here is the program: program Project16; {$APPTYPE CONSOLE} uses SysUtils, Classes, … Read more
Very vague question. Are you saying you want one entry per line? If so you want to use something like a BufferedReader, read all the lines, save them as a String array. Create a new JComboBox passing in that String constructor. BufferedReader input = new BufferedReader(new FileReader(filePath)); List<String> strings = new ArrayList<String>(); try { String … Read more
Try this: var pageExecute = { fileContents:”Null”, pagePrefix:”Null”, slides:”Null”, init: function () { $.ajax({ url: “./seeds/Ag.txt”, async: false, success: function (data){ pageExecute.fileContents = data; } }); } };
Just use file function with FILE_IGNORE_NEW_LINES flag. The file reads a whole file and returns an array contains all of the file lines. Each line contains new line character at their end as default, but we can enforce trimming by FILE_IGNORE_NEW_LINES flag. So it will be simply: $lines = file(‘file.txt’, FILE_IGNORE_NEW_LINES); The result should be: … Read more