text-files

Convert factor to integer in a data frame

自作多情 提交于 2019-12-17 09:52:43
问题 I have the following code anna.table<-data.frame (anna1,anna2) write.table<-(anna.table, file="anna.file.txt",sep='\t', quote=FALSE) my table in the end contains numbers such as the following chr start end score chr2 41237927 41238801 151 chr1 36976262 36977889 226 chr8 83023623 83025129 185 and so on...... after that i am trying to to get only the values which fit some criteria such as score less than a specific value so i am doing the following anna3<-"data/anna/anna.file.txt" anna.total<

Read a local text file using Javascript

霸气de小男生 提交于 2019-12-17 09:32:22
问题 I have read some of the previous questions on this topic but I really need to be 100% sure! Is it possible to read from a .txt file on my local system and present it in my HTML-BODY? I have tried several functions, here is one: function readFile (path) { var fso = new ActiveXObject('Scripting.FileSystemObject'), iStream=fso.OpenTextFile(path, 1, false); while(!iStream.AtEndOfStream) { document.body.innerHTML += iStream.ReadLine() + '<br/>'; } iStream.Close(); } readFile("testing.txt"); The

Text file in VBA: Open/Find Replace/SaveAs/Close File

柔情痞子 提交于 2019-12-17 06:45:23
问题 Here is pseudocode for what I am hoping to do: Open text File Find "XXXXX" and Replace with "YYYY" Save text File As Close text file This is what I have so far Private Sub CommandButton1_Click() Dim sBuf As String Dim sTemp As String Dim iFileNum As Integer Dim sFileName As String ' Edit as needed sFileName = "C:\filelocation" iFileNum = FreeFile Open sFileName For Input As iFileNum Do Until EOF(iFileNum) Line Input #iFileNum, sBuf sTemp = sTemp & sBuf & vbCrLf Loop Close iFileNum sTemp =

Remove unicode characters from textfiles - sed , other bash/shell methods

允我心安 提交于 2019-12-17 03:39:38
问题 How do I remove unicode characters from a bunch of text files on the terminal? I've tried this but it didn't work: sed 'g/\u'U+200E'//' -i *.txt I need to remove these unicodes from the textfiles U+0091 - sort of weird "control" space U+0092 - same sort of weird "control" space A0 - non-space break U+200E - left to right mark 回答1: If you want to remove ONLY particular characters and you have python, you can: CHARS=$(python -c 'print u"\u0091\u0092\u00a0\u200E".encode("utf8")') sed 's/['"

Java: How to read a text file

左心房为你撑大大i 提交于 2019-12-16 19:46:53
问题 I want to read a text file containing space separated values. Values are integers. How can I read it and put it in an array list? Here is an example of contents of the text file: 1 62 4 55 5 6 77 I want to have it in an arraylist as [1, 62, 4, 55, 5, 6, 77] . How can I do it in Java? 回答1: You can use Files#readAllLines() to get all lines of a text file into a List<String> . for (String line : Files.readAllLines(Paths.get("/path/to/file.txt"))) { // ... } Tutorial: Basic I/O > File I/O >

Read each line of text of each file in a directory and place into array?

被刻印的时光 ゝ 提交于 2019-12-14 04:23:30
问题 I have a directory with text files in it and new text files getting added each day. Each text file is a school lesson with 4 lines of text. Line 1 is Lesson Number, line 2 is Lesson Title, line 3 is Description, and line 4 is Due Date. I need, in PHP, to be able to read all current and future text files and place them into an HTML table. 4 columns in a table labeled Lesson Number, Lesson Title, Description, and Due Date. Each text file being 1 table row. I've made a site to help out some

What's the best way to generate a Text file in a .net website?

南楼画角 提交于 2019-12-14 03:51:14
问题 I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server? Edit: to answer a question down below, this is going to be a download once and then throw-away kind of file. Update: I glued together the suggestions by John Rudy and DavidK, and it worked perfectly. Thanks, all! 回答1: The answer will depend on whether, as Forgotten

How to write more than once to text file using PrintWriter

一世执手 提交于 2019-12-14 03:49:13
问题 I know how to create a PrintWriter and am able to take strings from my gui and print it to a text file. I want to be able to take the same program and print to the file adding text to the file instead of replacing everything already in the text file. How would I make it so that when more data is added to the text file, it is printed on a new line every time? Any examples or resources would be awesome. 回答1: try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("outfilename"

How to save results from the game to text file [closed]

爷,独闯天下 提交于 2019-12-14 03:38:08
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . here is the tic tac toe game in java, can somebody complete the program that it will save how many times win X and how many times O into the text file, please :) package xo2; import java.awt.*; import java.awt

Is there a way to output text to a file in different colors on Linux?

冷暖自知 提交于 2019-12-14 02:21:05
问题 I am outputting data to a txt file on Linux using C++. Is there a way to output a portion of a line of text in a different color? For example, I'd like to be able to write 0.000 Watts in red. Total Power Usage of this model: 0.000 Watts 回答1: Plain text files (*.txt) don't support color in any way. You will have to use a different format, such as RTF or HTML. 回答2: If you are willing to embed ANSI terminal escape codes in your file then, sure. Here is an example using Ruby for pseudocode. (The