text-files

Is there a better way to process a 300,000 line text file data and insert it into MySQL?

巧了我就是萌 提交于 2019-12-10 00:25:28
问题 What I'm doing right now is reading the contents of the text file and store it in a variable. After reading the whole content, I run a loop for the chunk data and in there call a function that will read to each line of the chunk data and pass every line to another function that process the processing of each column of data and inserting it in the database by batch. The batch is the whole chunk. The code process too long for every file with more than 500KB size. My problem is there is no

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

丶灬走出姿态 提交于 2019-12-09 07:39:34
问题 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

PHP login from text file

筅森魡賤 提交于 2019-12-09 07:00:09
问题 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>

Processing huge text files

半城伤御伤魂 提交于 2019-12-09 06:21:46
问题 Problem: I've a huge raw text file (assume of 3gig), I need to go through each word in the file and find out that a word appears how many times in the file. My Proposed Solution: Split the huge file into multiple files and each splitted file will have words in a sorted manner. For example, all the words starting with " a " will be stored in a " _a.dic " file. So, at any time we will not execeed more than 26 files. The problem in this approach is, I can use streams to read the file, but wanted

Get a subset of lines from a big text file using PowerShell v2

☆樱花仙子☆ 提交于 2019-12-08 23:33:21
问题 I'm working with a big text file, I mean more than 100 MB big, and I need to loop through a specific number of lines, a kind of subset so I'm trying with this, $info = Get-Content -Path $TextFile | Select-Object -Index $from,$to foreach ($line in $info) { ,,, But it does not work. It is like if it only gets the first line in the subset. I don't find documentation about the Index attribute, so is this possible or should I try using a different approach considering the file size? 回答1: PS> help

How do I limit (or truncate) text file by number of lines?

别来无恙 提交于 2019-12-08 23:10:14
问题 I would like to use a terminal/shell to truncate or otherwise limit a text file to a certain number of lines. I have a whole directory of text files, for each of which only the first ~50k lines are useful. How do I delete all lines over 50000? 回答1: In-place truncation To truncate the file in-place with sed, you can do the following: sed -i '50001,$ d' filename -i means in place. d means delete. 50001,$ means the lines from 50001 to the end. You can make a backup of the file by adding an

Printing to a file in C

こ雲淡風輕ζ 提交于 2019-12-08 19:16:21
问题 How do I print to an empty .txt file I already have created? I already print the results to the console, and now I want to print to a file named "Output.txt" . I've tried a couple of things that haven't worked, but I think it was easier to create a duplicate printDictionary() specifically for printing to a file called printDictionaryToFile() . I'm a little lost on how to do it though. Can anyone correct me on where I went wrong? I already added an extra FILE type called *out for my output to

navigating text file searches in python

扶醉桌前 提交于 2019-12-08 18:22:26
here is sample of the text file I am working with: <Opera> Tristan/NNP and/CC Isolde/NNP and/CC the/DT fatalistic/NN horns/VBZ The/DT passionate/JJ violins/NN And/CC ominous/JJ clarinet/NN ;/: The capital letters after the forward slashes are weird tags. I want to be able to search the file for something like "NNP,CC,NNP" and have the program return for this segment "Tristan and Isolde" , the three words in a row that match those three tags in a row. The problem I am having is I want the search string to be user inputed so it will always be different. I can read the file and find one match but

Current file line number with $. variable

*爱你&永不变心* 提交于 2019-12-08 16:10:24
问题 I understand that I can get the current line number of a file I am looping through with the builtin variable $. . As an experiment, I used that to prefix each line in a file with the value of $. (the current line number). However, this did not work as expected. I.e. given the following file contents line one line two line three then I would expect the following code to prefix each line with its line number for my $line (<FILE>) { print "$. : $line"; } but, instead, it gives the following

Writing a matrix to a text file

[亡魂溺海] 提交于 2019-12-08 14:09:13
问题 So i have done how to read a matrix from a text file where the first line defines the elements, however my question is how would i do the opposite that would write to the text file. I would like it to ask the user for the row 0 column 0, and add on, and have this code to write into the console, but do not know how to do into a text file This is the code to write into console: Dim size As Integer = 3 Dim numberWidth As Integer = 2 Dim format As String = "D" & numberWidth Dim A(size - 1, size -