file-io

Fstream open file in std::fstream::in | std::fstream::out | std::fstream::app mode

孤街浪徒 提交于 2019-12-24 12:41:32
问题 I need to be able to create a non-existent file. The design is as follows : I have 1 thread for all file IO, and in the data structure that encapsulates the file, I have a std::fstream file_handle. Can I create and open this file in the mode - std::fstream::in | std::fstream::out | std::fstream::app ? I need this because I have to use this one handle to do both - reads, and writes to the end of the file. However this is not creating the file. Here's what I have : class file_io { std::string

How to traverse directory in order of modification date without visiting all files in directory at least once in Python

拟墨画扇 提交于 2019-12-24 12:37:14
问题 I have a directory that is full of potentially millions of files. These files "mark" themselves when used, and then my Python program wants to find the "marked" ones then record that they were marked and unmark them. They are individual html files so they can't easily communicate with the python program themselves during this marking process (the user will just open whatever ones they choose). Because they are marked when used, if I access them by modification date, one at a time, once I

Java Scanner Changing String

ε祈祈猫儿з 提交于 2019-12-24 12:24:28
问题 I'm doing some basic file reading from a text file using Scanner. The first 5 entries are this - 0 MR2Spyder 1 Tundra 3 Echo 3 Yaris 4 ScionxB 4 ScionxD I instantiate the scanner normally and then do this - String line = scanner.nextLine(); System.out.println(line); I then get this output - ÿþ0 M R 2 S p y d e r Which doesn't make sense to me- is there some problem with the Scanner class? Should I be using BufferedReader? 回答1: Your file is encoded using UTF-16... the spaces between characters

Writing to a file with xyz format

馋奶兔 提交于 2019-12-24 12:04:25
问题 I want to write x points and y points in a trajectory file with the xyz format. But I am a beginner in python, and this code gives the error unexpected character after line continuation character . The first line is number of atoms, second line is a comment, and third line is coordinates. xyz.close() 回答1: The problem is this line, with the character \ (which python may think is a line continuation character in certain contexts). When you fix that, you'll also have the problem that %8x and %8z

Sharing Violation on image View and Edit WPF

折月煮酒 提交于 2019-12-24 12:01:15
问题 I'm working on MVVM and WPF application. I have a scenario in which i have to edit the viewing image and save it. I have used RadCarousel in which using the ContextMenu on right click i'm editing the image using mspaint . When i try to save the edited image i get the " Sharing violation error on path ". The images are located in a shared folder. //XAML Code: <telerik:RadCarousel x:Name="MarketSeriesCarousel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Path

How to replace a column using Python's built-in .csv writer module?

核能气质少年 提交于 2019-12-24 10:52:10
问题 I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to implement the solution in python. I'm having trouble with the "replace" part of the solution. I've read the official csv module documentation about how to use the writer, but there isn't really a clear enough example for me (yes, I'm slow). So, now for the question: how does one iterate through the

Reading and Plotting from text files

感情迁移 提交于 2019-12-24 09:49:24
问题 I have some problems in reading data from text file and plotting it.The text file contains Date; Time; Temp °C 05.08.2011; 11:00:47;23.75 05.08.2011; 11:01:21;23.69 05.08.2011; 11:01:56;25.69 05.08.2011; 11:02:16;23.63 05.08.2011; 11:02:50;23.63 05.08.2011; 11:03:24;23.63 I want to plot the Temperature values with elapsed minutes. firstly i used [a,b]=textread('file1.txt','%s %s','headerlines',1) to read the data in a string and I get '17:09:16;21.75' After that I used a= strread('17:08:00;21

Reading a known number of variable from a file when one of the variables are missing in input file

↘锁芯ラ 提交于 2019-12-24 09:49:03
问题 I already checked similar posting. The solution is given by M. S. B. here Reading data file in Fortran with known number of lines but unknown number of entries in each line So, the problem I am having is that from text file I am trying to read inputs. In one line there is supposed to be 3 variables. But sometimes the input file may have 2 variables. In that case I need to make the last variable zero. I tried using READ statement with IOSTAT but if there is only two values it goes to the next

How to append data to text file in python 2.7.11?

别等时光非礼了梦想. 提交于 2019-12-24 09:33:20
问题 Could any one show me how i can add hyperlinks to new line in text file? If there is already data in first line of text file i want the data get inserted in the next empty line. I am writing multiple hyperlinks to text file(append). Thanks in advance. print "<a href=\"http://somewebsite.com/test.php?Id="+str(val)+"&m3u8="+lyrics+"&title=test\">"+str(i)+ "</a> <br />"; 回答1: Take a look at the python docs. You can use the with open statement to open the file. with open(filename, 'a') as f: f

How can I determine the number of bytes of each line of a file in java?

吃可爱长大的小学妹 提交于 2019-12-24 09:28:22
问题 I have a very big text file. I want to determine the number of bytes of each line and save it in another file. 回答1: Using java.io.BufferedReader, you can easily read each line as a separate String. The number of bytes used by a line depends on the encoding used. For a simple ASCII encoding, you can simply use the length of the String, since each character takes up one byte. For multi-byte encodings like UTF-8, you would need a more complicated approach. 回答2: The following code extracts byte[]