text-files

Most efficient way to “nibble” the first line of text from a text document then resave it in python

自作多情 提交于 2019-12-11 08:37:37
问题 I have a text document that I would like to repeatedly remove the first line of text from every 30 seconds or so. I have already written (or more accurately copied) the code for the python resettable timer object that allows a function to be called every 30 seconds in a non blocking way if not asked to reset or cancel. Resettable timer in python repeats until cancelled (If someone could check the way I implemented the repeat in that is ok, because my python sometimes crashes while running

Python how to grab certain number of lines after match

怎甘沉沦 提交于 2019-12-11 08:36:54
问题 Let's say I have an input text file of the following format: Section1 Heading Number of lines: n1 Line 1 Line 2 ... Line n1 Maybe some irrelevant lines Section2 Heading Number of lines: n2 Line 1 Line 2 ... Line n2 where certain sections of the file start with a header line that specifies how many lines are in that section. Each section heading has a different name. I have written a regular expression that will match the header line based on the header name the user searches for each section,

how to split a text file and modify it in Python?

岁酱吖の 提交于 2019-12-11 08:29:14
问题 I currently have a text file that reads like this: 101, Liberia, Monrovia, 111000, 3200000, Africa, English, Liberia Dollar; 102, Uganda, Kampala, 236000, 34000000, Africa, English and Swahili, Ugandan Shilling; 103, Madagascar, Antananarivo, 587000, 21000000, Africa, Magalasy and Frances, Malagasy Ariary; I'm currently printing the file using this code: with open ("base.txt",'r') as f: for line in f: words = line.split(';') for word in words: print (word) What I would like to know is, how

android app crashes when trying to get txt file from webserver

ⅰ亾dé卋堺 提交于 2019-12-11 07:54:48
问题 my app crashes when trying to get a remote txt file. even if just try to parse a url it crashes. internet permission is set and the device/vm has connection to the internet. LogCat: code snippet: try { // the following line is enough to crash the app URL url = new URL("http://www.i.am/not/going/to/show/you/this.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = in.readLine()) != null) { //get lines } in.close(); } catch

Calling a function within fprintf syntax in C language

你。 提交于 2019-12-11 07:04:35
问题 I'm trying to print my strings output into a separate file. The issue I'm running into right now is the fact that my code carries a function for a set of strings that adds dashed lines underneath my columns (purely cosmetics). How do I call this function inside my fprintf code? #include <stdio.h> /* function for the dash-line separators*/ void dashes (void) { printf (" ---- ----- -------------------- --------------\n"); } /* end of function definition */ /* main program */ #include <stdio.h>

Error in a Word VBA macro, trying to insert values into bookmarks

自古美人都是妖i 提交于 2019-12-11 06:35:43
问题 I'm trying to write a Word macro which inserts data from the Current User in Registry into predefined bookmarks in the document. I've got an ini-file which dictates what the names of each registry entry is, and that value is then imported into a loop in the Word Macro. This works fine (I think), but the Word macro needs to insert the data into the document as well. And this works fine if the bookmarks are there, but if they aren't, the macro seems to insert data anyway. I don't want that. I

Bind to resource text file

自作多情 提交于 2019-12-11 06:25:47
问题 I want to bind to a text block to a text file which is compiled as a resource. Is there a way to bind it like a image with the source property and a pack uri? <Image Source="pack://application:,,,/Properties/..."/> 回答1: Well, you certainly can't do it exactly the same way. If you try this: <TextBox Text="pack://application:,,,/Properties/..."/> ...it just displays the pack uri as text -- not what you want. One possible solution is to create your own MarkupExtension . For example: public class

C++ Read Entire Text File

徘徊边缘 提交于 2019-12-11 06:07:26
问题 i try to read the entire text file using vc++ with this code ifstream file (filePath, ios::in|ios::binary|ios::ate); if (file.is_open()) { size = (long)file.tellg(); char *contents = new char [size]; file.seekg (0, ios::beg); file.read (contents, size); file.close(); isInCharString("eat",contents); delete [] contents; } but it's not fetch all entire file ,why and how to handle this? Note : file size is 1.87 MB and 39854 line 回答1: You are missing the following line file.seekg (0, file.end);

Getting when a text file is edited by another program

我只是一个虾纸丫 提交于 2019-12-11 05:13:34
问题 So I have a python script (let's call it file_1.py ) that overwrites the content of a text file with new content, and it works just fine. I have another python script ( file_2.py ) that reads the file and performs actions on the data in the file. With file_2.py I've been trying to get when the text file is edited by file_1.py and then do some stuff with the new data as soon as it's added. I looked into the subprocess module but I couldn't really figure out how to use it across different files

Java program - Counts all the words from a text file, and counts frequency of each word

亡梦爱人 提交于 2019-12-11 04:32:22
问题 I'm a beginner programmer and I'm trying to do one program that opens a text file with a large text inside and then it counts how many words it contains. Then it should write how many different words are in the text, and write the frecuency of each word in the text. I had the intention to use one array-string to store all unique words and one int-string to store the frequency. The program counts the words, but I'm a little bit unsure about how could I write the code correctly to get the list