text-files

How to convert a tab separated file to CSV format?

走远了吗. 提交于 2019-12-03 09:54:48
I have a text file in this format : { attribute1 attribute2 attribute3.... attributeN value"A" value"B" value"C".... value"Z" /* next line of values*/ } Each word is separated by a tab. How do I convert to CSV format? I tried using Excel but it's giving compatibility issues. Import the data with excel (Data > Load from text file), using tab as a column separator. Then save the file as csv. It cannot have compatibility issues, it's a basic task and i did it quite often in the past. If you can use a scripting language , you might give Python a shot: import csv # read tab-delimited file with open

How can I compare files in a JUnit test case? [duplicate]

送分小仙女□ 提交于 2019-12-03 09:47:15
This question already has answers here : Comparing text files with Junit (9 answers) I want to implement JUnit on a small project I'm working on because I want to learn a little bit about it. The tutorials that I read all make reference to methods that have a particular output. In my case my output are files, how can I do this? any simple example? any approach that could help me with this? The files are raw text files that are build by a void private method. You want to get a correct output file for a given set of inputs, and setup a test to call your void method with those inputs, and then

PHP login from text file

て烟熏妆下的殇ゞ 提交于 2019-12-03 08:56:20
Hi I have looked at other posts about this but they are 2 or more years old so I thought it was better to start fresh. As the title suggests I am trying to make a login page with php. Users should be able to login to a special member only page. The usernames and passwords are stored in a textfile (note this is for an assignment otherwise I'd use SQL). My code is below ?php echo "Username: <input type=\"text\" name=\user-name\"><br>"; echo "Password: <input type=\"text\" name=\pass-word\"><br>"; echo "<input type=\"submit\" value=\"login\" name=\"login\"><br>"; $userN = $_POST['user-name'];

Organizing the output of my shell script into tables within the text file

混江龙づ霸主 提交于 2019-12-03 08:46:53
I am working with a unix shell script that does genome construction then creates a phylogeny. Depending on the genome assembler you use, the final output (the phylogeny) may change. I wish to compare the effects of using various genome assemblers. I have developed some metrics to compare them on, but I need help organizing them so I can run useful analyses. I would like to import my data into excel in columns. This is the script I am using to output data: echo "Enter the size (Mb or Gb) of your data set:" read SIZEOFDATASET echo "The size of your data set is $SIZEOFDATASET" echo "Size of Data

Remove empty lines from txtfiles, remove spaces from start and end of line

*爱你&永不变心* 提交于 2019-12-03 08:31:39
问题 Which one would be better: sed -e '/^$/d' *.txt sed 'g/^$/d' -i *.txt Also, how do I remove spaces from beginning and end of each line in the text file? 回答1: $ sed 's/^ *//; s/ *$//; /^$/d' file.txt `s/^ *//` => left trim `s/ *$//` => right trim `/^$/d` => remove empty line 回答2: Even more simple method using awk. cat filename.txt | awk 'NF' | awk '{$1=$1;print}' awk 'NF' - This will remove all blank/empty lines. awk '{$1=$1;print}' - This will remove only trailing white spaces, (both left and

Export Core Data Entity as text files in Cocoa

那年仲夏 提交于 2019-12-03 08:02:26
问题 I have an entity in core data that has 2 Attributes. One that is a string called "name", and another one that is a string called "message". I need a method to create text files for all the attributes that the user has added. I wan't the files names to be the name attribute and the contents to be the message attribute. If anyone knows how to do this any help would be great. Thanks for any help 回答1: Have you given any thought at all to the steps involved? Create a fetch request (possibly with a

Reading From A Text File - Batch

*爱你&永不变心* 提交于 2019-12-03 06:14:23
I have a text file, a.txt: Hello World Good Afternoon I have written a batch script to read contents of this file line by line: FOR /F "tokens=* delims=" %%x in (a.txt) DO echo %%x I am getting output as "Hello" "World" due to default behaviour of delimiter(space). How can I override this behaviour to get the ouptut as "Hello World" "Good Afternoon" Your code "for /f "tokens=* delims=" %%x in (a.txt) do echo %%x" will work on most Windows Operating Systems unless you have modified commands. So you could instead "cd" into the directory to read from before executing the "for /f" command to

How to add duplicate keys into the Dictionary

非 Y 不嫁゛ 提交于 2019-12-03 04:54:14
问题 I have some lines from text files that i want to add into the Dictionary.I am using Dictionary for the first time.While adding up starting lines it was Ok but suddenly i got error: An item with the same key has already been added Here in my code there are duplicate keys which i can not change.Here is my code in c# Dictionary<string, string> previousLines = new Dictionary<string, string> { }; previousLines.Add(dialedno, line); Here dialedno is the key and line is the textfile line. Here is the

Count number of blank lines in a file

故事扮演 提交于 2019-12-03 04:44:23
问题 In count (non-blank) lines-of-code in bash they explain how to count the number of non-empty lines. But is there a way to count the number of blank lines in a file? By blank line I also mean lines that have spaces in them. 回答1: Another way is: grep -cvP '\S' file -P '\S' (perl regex) will match any line contains non-space -v select non-matching lines -c print a count of matching lines If your grep doesn't support -P option, please use -E '[^[:space:]]' 回答2: One way using grep : grep -c "^$"

Mime type for .txt files?

三世轮回 提交于 2019-12-03 04:09:18
I´m trying to share a .txt file with share intent. If I set "text/plain" as mime type, it reads the content like text not like text file, then the options given in the share menu are Whatsapp, Line, etc.. Does anybody know how to configure the share intent so that the share options are only the programs that are able to send a .txt file (Gmail, Dropbox, etc.. but not Whatsapp..)? Thanks You can try the specific mime: text/plain or, the more general text mime: text/* tony gil simple and complete example code (less than 50 lines) for app that android will present to the user along with menu list