text-files

Extract text between HTML tags

﹥>﹥吖頭↗ 提交于 2019-12-18 05:07:21
问题 I have many HTML files from which I need to extract text. If it's all on one line, I can do that quite easily but if the tag wraps around or is on multiple lines I can't figure how to do this. Here's what I mean: <section id="MySection"> Some text here another line here <br> last line of text. </section> I'm not concerned about the <br> text, unless it will help wrap the text around. The area that I want always begins with "MySection" and then is ended with </section> . What I'd like to end

Read txt file in Matlab

好久不见. 提交于 2019-12-18 04:55:09
问题 I have a trouble reading the txt file, which contains 10 columns and 2 lines of header, but the problem is that in the middle of the file the same header appears several times and textread() doesnt function. That's my file example: file.txt headerline1 aaaa headerline2 111 123 20/12/2000 name1 name2 name3... name8 0 21/12/2000 name1 name2 name3... name8 0 22/12/2000 name1 name2 name3... name8 0 headerline1 aaaa headerline2 111 123 25/12/2000 name1 name2 name3... name8 0 27/12/2000 name1 name2

Writing TXT File with PHP, Want to Add an Actual Line Break

江枫思渺然 提交于 2019-12-18 03:59:18
问题 I am writing a TXT file using PHP. I want to insert actual line breaks into the TXT file wherever necessary. I have tried all combinations of \n \r \r\n \n\r ... but these are not causing any linebreaks to appear - in most cases, I am seeing the text "\n" appear in the TXT file, with no linebreak. I have also tried chr(13). Any other ideas would be appreciated. 回答1: Sounds to me like you might be using single quotes, i.e. '\n' rather than "\n" . If you wanted to continue with a single quotes

remove empty lines from text file with PowerShell

扶醉桌前 提交于 2019-12-18 01:42:13
问题 I know that I can use: gc c:\FileWithEmptyLines.txt | where {$_ -ne ""} > c:\FileWithNoEmptyLines.txt to remove empty lines. But How I can remove them with '-replace' ? 回答1: I found a nice one liner here >> http://www.pixelchef.net/remove-empty-lines-file-powershell. Just tested it out with several blanks lines including newlines only as well as lines with just spaces, just tabs, and combinations. (gc file.txt) | ? {$_.trim() -ne "" } | set-content file.txt See the original for some notes

Comparing text files with Junit

半世苍凉 提交于 2019-12-17 21:55:23
问题 I am comparing text files in junit using: public static void assertReaders(BufferedReader expected, BufferedReader actual) throws IOException { String line; while ((line = expected.readLine()) != null) { assertEquals(line, actual.readLine()); } assertNull("Actual had more lines then the expected.", actual.readLine()); assertNull("Expected had more lines then the actual.", expected.readLine()); } Is this a good way to compare text files? What is preferred? 回答1: junit-addons has nice support

program can't find file after install

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 21:14:08
问题 i made a program that uses a pre-made text file that hold a list of sites. now in some computer the program works fine but, in my friend computer it doesn't. i check the program on 2 of my windows 7 computers, and 1 xp and i don't have any errors. this program was used for some time on XP, now my friend want to install it in his windows 7 computer at home, but the program doesn't find the file after he install the program. this is the error he get: System.IO.FileNotFoundException: file not

Removing similar lines from two files

对着背影说爱祢 提交于 2019-12-17 20:54:51
问题 I'm trying to find a PowerShell solution to remove lines from file A that are similar in File B. Compare-Object $A $B does the comparing, but how to I go about deleting the items? File A yahoo.com google.com stackoverflow.com facebook.com twitter.com File B stackoverflow.com facebook.com After Compare: File A yahoo.com google.com twitter.com 回答1: You can remove the contents of file B from file A with something like this: $ref = Get-Content 'C:\path\to\fileB.txt' (Get-Content 'C:\path\to\fileA

Is it possible to speed-up python IO?

筅森魡賤 提交于 2019-12-17 19:15:30
问题 Consider this python program: import sys lc = 0 for line in open(sys.argv[1]): lc = lc + 1 print lc, sys.argv[1] Running it on my 6GB text file, it completes in ~ 2minutes. Question: is it possible to go faster? Note that the same time is required by: wc -l myfile.txt so, I suspect the anwer to my quesion is just a plain "no". Note also that my real program is doing something more interesting than just counting the lines, so please give a generic answer, not line-counting-tricks (like keeping

How to list all text (non-binary) files in a git repository?

空扰寡人 提交于 2019-12-17 18:43:21
问题 I have a repository with a lot of autogenerated source files I've marked as "binary" in .gitattributes (they are checked in because not everyone has access to the generator tools). Additionally, the repo has a lot of source-ish files in ignored directories (again, generated as part of the build processes), and a number of actual binary files (e.g. little resource files like icons). I'd now like to find all the non-auto-generated and non-ignored files in the repo. I thought I'd just do this

Load .txt file using JQuery or Ajax

↘锁芯ラ 提交于 2019-12-17 09:56:32
问题 How can I fix the script below so that it will work EVERY TIME! Sometimes it works and sometimes it doesn't. Pro JQuery explains what causes this, but it doesn't talk about how to fix it. I am almost positive it has to do with the ajax ready state but I have no clue how to write it. The web shows about 99 different ways to write ajax and JQuery, its a bit overwhelming. My goal is to create an HTML shell that can be filled with text from server based text files. For example: Let's say there is