text-files

What is the best way to read a text file two lines at a time in Java?

空扰寡人 提交于 2019-12-04 04:37:11
问题 BufferedReader in; String line; while ((line = in.readLine() != null) { processor.doStuffWith(line); } This is how I would process a file line-by-line. In this case, however, I want to send two lines of text to the processor in every iteration. (The text file I'm processing essentially stores one record on two lines, so I'm sending a single record to the processor each time.) What's the best way of doing this in Java? 回答1: Why not just read two lines? BufferedReader in; String line; while (

Entity Framework with text files (no database!)

情到浓时终转凉″ 提交于 2019-12-04 03:33:08
问题 I'm used to Forms and DataSets but now I'm trying out WPF and the Entity Framework. My goal is to fill a DataGrid in WPF with the use of the Entity Framework. However, I do NOT have a database! I have simple text files with data that I have to parse to fill my Entities. However, I get errors like "Entity type 'TableName' is not mapped." and crashes like that I don't have a connection string. Is it possible to use the Entity Framework without a database? Or do I have to go back to use a

Extracting columns containing a certain name

前提是你 提交于 2019-12-04 03:14:14
问题 I'm trying to use it to manipulate data in large txt-files. I have a txt-file with more than 2000 columns, and about a third of these have a title which contains the word 'Net'. I want to extract only these columns and write them to a new txt file. Any suggestion on how I can do that? I have searched around a bit but haven't been able to find something that helps me. Apologies if similar questions have been asked and solved before. EDIT 1: Thank you all! At the moment of writing 3 users have

StreamWriter.WriteLine() is not working

你说的曾经没有我的故事 提交于 2019-12-04 01:07:39
问题 I am trying to write several lines, one at a time, to a .txt file using StreamWriter.WriteLine (Not statically). const string filename = "BasicTestInfo.txt"; using (var writer = new StreamWriter(filename, false)) { writer.WriteLine("{0} 350 200 200 10 2 28 20 200 2500 1200 1 1", Player1); writer.WriteLine("{0} 300 150 150 4 2 15 18 150 2500 1000 1 0", Player2); writer.WriteLine("{0} 200 140 450 25 14 10 70 4500 2500 750 1 1", Player3); writer.WriteLine("{0} 175 120 400 15 3 8 50 3000 2500 850

python opens text file with a space between every character

我们两清 提交于 2019-12-04 00:22:47
Whenever I try to open a .csv file with the python command fread = open('input.csv', 'r') it always opens the file with spaces between every single character. I'm guessing it's something wrong with the text file because I can open other text files with the same command and they are loaded correctly. Does anyone know why a text file would load like this in python? Thanks. Update Ok, I got it with the help of Jarret Hardie's post this is the code that I used to convert the file to ascii fread = open('input.csv', 'rb').read() mytext = fread.decode('utf-16') mytext = mytext.encode('ascii', 'ignore

vim: would like it to turn settings on only for certain file types

橙三吉。 提交于 2019-12-03 22:39:18
I've looked at this but it wasn't too much help. Maybe I didn't read it too well. Basically what I want is when I open a .txt file the settings: set wrap set linebreak are turned on. How might I go about doing that? Thanks in advance. Also, I'm using XP. My answer to that question still applies: Put autocmd commands based on the file suffix in your ~/.vimrc autocmd BufRead,BufNewFile *.txt set wrap linebreak As Luc says, you might prefer to autocmd BufRead,BufNewFile *.txt setlocal wrap linebreak if you're likely to open txt and non-txt files at the same time. Put this into ~/.vim/ftdetect

Fastest way to load data from text file then store it into database

旧时模样 提交于 2019-12-03 21:55:13
I have problem. I'm developing a project but I'm stuck in this part: I want to load a data from text file and store it into database access the things is the data inside each text file about 12.000 lines of data and each text file it takes about 10 minute to process it.. NOTE : before store the data, I separate each line of data from text file and put it into string then I check whether the data is already inside database or not. if inside the database I update it. If not then I use insert statement.. I'm using C# to develop this program? is there any fastest way to load and store this data?

Write mutiple lines to a text file using Visual Basic

会有一股神秘感。 提交于 2019-12-03 20:57:53
I'm trying to check to see if a file exists, if so it does nothing. If the file does not exist is creates the text file. Then I want to write text to that file. Where am I going wrong with this code? I'm just trying to write multiple lines to the text file and that part is not working. It is creating the text file... just not writing to it. Dim file As System.IO.FileStream Try ' Indicate whether the text file exists If My.Computer.FileSystem.FileExists("c:\directory\textfile.txt") Then Return End If ' Try to create the text file with all the info in it file = System.IO.File.Create("c:

Using Hibernate to work with Text Files

守給你的承諾、 提交于 2019-12-03 20:03:13
问题 I am using Hibernate in a Java application to access my Database and it works pretty well with MS-SQL and MySQL. But some of the data I have to show on some forms has to come from Text files, and by Text files I mean Human-Readable files, they can be CSV, Tab-Delimited, or even a key, value pair, per line since my data is as simple as this, but my preference of course is XML files. My question is: Can I use hibernate to read those files using HQL, Query , EntityManager and all those resources

Reading From A Text File - Batch

吃可爱长大的小学妹 提交于 2019-12-03 17:31:10
问题 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" 回答1: Your code "for /f "tokens=* delims=" %%x in (a.txt) do echo %%x" will work on most Windows Operating Systems unless you have modified