text-files

Split text file into smaller multiple text file using command line

半世苍凉 提交于 2019-11-29 19:39:47
I have multiple text file with about 100,000 lines and I want to split them into smaller text files of 5000 lines each. I used: split -l 5000 filename.txt That creates files: xaa xab aac xad xbe aaf files with no extensions. I just want to call them something like: file01.txt file02.txt file03.txt file04.txt or if that is not possible, i just want them to have the ".txt" extension. I know the question has been asked a long time ago, but I am surprised that nobody has given the most straightforward unix answer: split -l 5000 -d --additional-suffix=.txt $FileName file -l 5000 : split file into

Searching for a Specific Word in a Text File and Displaying the line its on

和自甴很熟 提交于 2019-11-29 19:38:39
问题 I am having trouble attempting to find words in a text file in C#. I want to find the word that is input into the console then display the entire line that the word was found on in the console. In my text file I have: Stephen Haren,December,9,4055551235 Laura Clausing,January,23,4054447788 William Connor,December,13,123456789 Kara Marie,October,23,1593574862 Audrey Carrit,January,16,1684527548 Sebastian Baker,October,23,9184569876 So if I input "December" I want it to display "Stephen Haren

Tkinter Python GUI Issues

岁酱吖の 提交于 2019-11-29 18:26:20
Below is my code, it runs but I'm not sure how to get the "Run text" button to prompt me to open text file in new window, currently a new window appears with a "Quit" button, nothing else. import tkFileDialog import Tkinter as tk from Tkinter import * import logging logging.basicConfig(filename= "log_file.txt", filemode = "w", level=logging.DEBUG, format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %I:%M:%S %p') logging.warning('is when this event was logged.') class HomeScreen: def __init__(self, master): self.master = master self.frame = tk.Frame(self.master) self.button1 = tk.Button(self

How can I get uploaded file full path in C# 3.0?

允我心安 提交于 2019-11-29 17:40:22
In my ASP.NET MVC website, I have to read a txt file with some names and emails separeted by ';'. After that, I have to save each line of this txt file to database. Googling around, I've found some snippets, but in all of them I have to use the txt file path. But, how can I get this path? This file could be anywhere in a user's machine! Thanks!! You cannot get the full path of an uploaded file. This would be a privacy violation for the user that uploaded the file. Instead, you'll need to read the Request.Files that have been uploaded. For example: HttpPostedFile file = Request.Files[0]; using

Read Data From Text File And Sum Numbers

倾然丶 夕夏残阳落幕 提交于 2019-11-29 17:02:58
I want to read in data from a text file which is full of integers and have the program print those integers out to the screen while summing them. This shouldn't be hard, but I can't figure it out!!! Here is the extremely simplified text file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 And here is my code that is supposed to work: import java.util.*; import java.io.File; import java.io.IOException; public class ReadFile { public static void main(String[] args) throws IOException { Scanner textfile = new Scanner(new File("Some_Numbers.txt")); filereader(textfile); } static void

How is a+(read/append) different from a(append) in php

一曲冷凌霜 提交于 2019-11-29 16:58:23
I am reading(and slowly trying) the ways to interact with a txt file in php. I have already tried append and it adds data to the end of the txt file But how is a+ different from a In w3schools it says: a Append. Opens and writes to the end of the file or creates a new file if it doesn't exist a+ Read/Append. Preserves file content by writing to the end of the file What does a+ do differently and what does it actually "Preserve" With a you can just append to the end of the file. With a+ you can read the file too, so you can move the file pointer using fseek and add content somewhere else inside

Batch - edit specified line in text file

无人久伴 提交于 2019-11-29 16:45:27
For example, line number 2 reads: "0" (without quotes). I want to change that 0 to a 1, without changing anything else in the text file. I know what line the values will be on, so all i need to know is how to change that value to another value that I specify. I also will have to to the same with strings, not just numbers. Example: From: 4.7 0 check 0 1 0 0 To: 4.7 1 check 0 1 0 0 Thanks! try this: @ECHO OFF &SETLOCAL SET "file=file" SET /a Line#ToSearch=2 SET "Replacement=0" (FOR /f "tokens=1*delims=:" %%a IN ('findstr /n "^" "%file%"') DO ( SET "Line=%%b" IF %%a equ %Line#ToSearch% SET "Line=

Read text file in Java

冷暖自知 提交于 2019-11-29 15:11:58
I have a text file. I would like to retrieve the content from one line to another line. For example, the file may be 200K lines. I want to read the content from line 78 to line 2735. Since the file may be very large, I do not want to read the whole content into the memory. Here's a start of a possible solution: public static List<String> linesFromTo(int from, int to, String fileName) throws FileNotFoundException, IllegalArgumentException { return linesFromTo(from, to, fileName, "UTF-8"); } public static List<String> linesFromTo(int from, int to, String fileName, String charsetName) throws

StreamWriter limit in C# in text file

会有一股神秘感。 提交于 2019-11-29 13:56:39
I have an array list which contains 100 lines. When i try to export it into a text file (txt), the output is only 84 lines and it stops in the middle of the 84th line. When I looked at the file size it showed exactly sharp 4.00KB as if there is some kind of a limit to the stream writer. I tried using different parameters etc. but it kept happening. Here is the code: FileStream fs = new FileStream(path, FileMode.Create); StreamWriter sw = new StreamWriter(fs); ArrayList chartList = GetChart(maintNode); foreach (var line in chartList) { sw.WriteLine(line); } fs.Close(); Console.WriteLine("Done")

Why doesn't fwrite() write a Binary File using “wb”, in C, on Mac OS X?

与世无争的帅哥 提交于 2019-11-29 13:54:03
For the sake of learning C and understanding the difference between Binary Files and Text Files, I'm attempting to write a string to file as both file types like so: char * string = "I am a string!"; FILE * filePtrA = fopen("/output.txt", "wt"); fwrite(string, strlen(string), 1, filePtrA); FILE * filePtrB = fopen("/output.bin", "wb"); fwrite(string, strlen(string), 1, filePtrB); fclose(filePtrA); fclose(filePtrB); However both "wt" and "wb" are writing as a Text File, where "wb" should be writing as a Binary File. Hex appears like so for both files: 49 20 61 6D 20 61 20 73 74 72 69 6E 67 21