text-files

why does my vba code see comma as new line?

[亡魂溺海] 提交于 2019-12-11 01:33:16
问题 I have this code that reads from text file, when line starts with "Q" its a question and "R" and "W" are wrong and right answers respectively that are read unto shapes. However the problem is, if there is a comma anywhere in the text, my powerpoint macro sees it as a new line. any help on how to fix this please? Here is the code Open ActivePresentation.Path & "\" & "questions.txt" For Input As #1 nextSlideNum = 1 nextAnswerNum = 1 Do Until EOF(1) Input #1, nextLine If Left$(nextLine, 1) = "Q"

UISearchController for TableView

霸气de小男生 提交于 2019-12-11 01:06:10
问题 This is what my Table View looks like. Each cell Strings a text from a .txt Search Filter works fine. But When I select one of the results e.g. "How" it prints the the Content of "Hello" instead. I'm thinking this is probably because "Hello" is programmed as the first String so it will always be the result of the first cell when clicked. I am needing help with figuring out how the search results are linked to it's own content. if that makes any sense? Here's the code below. The code reads

Extracting selected data from a text file in Ruby

橙三吉。 提交于 2019-12-11 00:38:19
问题 Now I am working on extracting information from a text file in Ruby. Then how can I extract just the number '0.6748984055823062' from the following text file? { "sentiment_analysis": [ { "positive": [ { "sentiment": "Popular", "topic": "games", "score": 0.6748984055823062, "original_text": "Popular games", "original_length": 13, "normalized_text": "Popular games", "normalized_length": 13, "offset": 0 }, { "sentiment": "engaging", "topic": "pop culture-inspired games", "score": 0

Create New Text Files with Different Names in Java

亡梦爱人 提交于 2019-12-10 22:13:57
问题 Every time the code is executed I want a new Text File to be created. The Text File should be called Person1. Next time code is executed the Text File should be called Person2. Then again the Text File should be called Person3. etc, etc.... At the moment, I'm able to create a Text File named "Person1" but can't create another Text File named "Person2". private int fileNumber = 1; fileNumber = fileNumber++; public static void main(String[] args) { try { FileWriter fw = new FileWriter("Person"

Min and max functions returns incorrect values [duplicate]

*爱你&永不变心* 提交于 2019-12-10 21:30:16
问题 This question already has an answer here : Max function in python returning wrong results (1 answer) Closed last year . I am using python 2.7 to find highest and lowest values in an text file. The text file is simply formatted with one Integer value at each line. The following code collects the numbers from the file: with open(data_file, 'r') as f: data_list = f.readlines() Then I try to reach for the maximum and minimum values with: max_value = max(data_list) min_value = min(data_list) print

PHP read in every 10 out of 100 lines

a 夏天 提交于 2019-12-10 17:55:19
问题 I'm trying to read in a text file of 5000 lines. However I only want to get the first 10 lines of every 100 lines. So line 1-10, line 101 - 110, line 200 - 210 etc. I just cant figure out the logic to use. $count = count(file($text)) for ($i = 0; $i < $count; $i++) { $test = fgets($f_text) } 回答1: Use % 100 and only print lines where $n % 100 > 0 && $n % 100 <= 10 . $lines = file($text); foreach ($lines as $n => $line) { if ($n % 100 > 0 && $n % 100 <= 10) { echo $line; // or whatever } } A

How to truncate a file down to certain size but keep the end section?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 12:46:50
问题 I have a text file that's appended to over time and periodically I want to truncate it down to a certain size, e.g. 10MB, but keeping the last 10MB rather than the first. Is there any clever way to do this? I'm guessing I should seek to the right point, read from there into a new file, delete old file and rename new file to old name. Any better ideas or example code? Ideally I wouldn't read the whole file into memory because the file could be big. Please no suggestions on using Log4Net etc.

Extracting data from text file

大城市里の小女人 提交于 2019-12-10 12:27:45
问题 I have a text file that starts like this: [Details] Version=100 Switch=340 Video=800 Date=20100912 Length=00:49:34.2 Days=1 hours=20 Is there a way that I can check each line within the [Details] section and then do something like this? if(line == "version") { // read the int 100 } Also there is other text in the text file that is of no interest to me. I only need to find the [Details] part. 回答1: using (StreamReader sr = new StreamReader(path)) { while (sr.Peek() >= 0) { var keyPair = sr

Python data text file grades program

梦想与她 提交于 2019-12-10 12:26:50
问题 Looking for help with my program. There is a text file with 5 first and last names and a number grade corresponding to each person. The task is to create a user name and change the number grade to a letter grade. The problem I am having is that the program is only outputting one line (or username) from the textfile and not all 5 lines (usernames). def main(): inFile = open("grades.txt", "r") aList = inFile.readlines() grades = ["F","E","D","C","B","A"] revised so that program will run for

reading integers from a text file in c#

陌路散爱 提交于 2019-12-10 12:19:24
问题 I have a text file containing the following content: 0 12 1 15 2 6 3 4 4 3 5 6 6 12 7 8 8 8 9 9 10 13 There are no spaces between two rows but there is a space between two numbers. I want to read these integers from a txt file and save the two columns into two different arrays in C#.Cn anyone help 回答1: Try the following: var r = File.ReadAllLines(path) .Select(line => line.Split(' ')) .Select(arr => new { Column0 = Int32.Parse(arr[0]), Column1 = Int32.Parse(arr[1]) // etc }) .ToArray(); Then: