Questions tagged [textreader]

68 questions
0
votes
0 answers

How to deal with UnicodeDecodeError while reading a file?

SNIPPET: with open("sample.txt", 'r') as f: filedata = f.read() ERROR that I get: UnicodeDecodeError Traceback (most recent call last) in 1 `with open("sample.txt", 'r') as f:` ----> 2 filedata =…
0
votes
1 answer

My code won`t add numbers together correctly when reading them from file

I want to add together numbers from a file. Numbers are 31 32 45 65 67 54 43 78 98 33 14 25. Answer should be 585, but code gives 287. Where do I go wrong and how to fix it? using System; using System.IO; namespace TaaviSimsonTest { class…
0
votes
0 answers

Using TextReader in multi target project

I'm using Analyzer with Code Fix template of .NET Compiler Platform SDK to create my Roslyn code analyzer. The template creates a solution, where the actual analyzer project is a multi-target one. (I did not find a way, to modify this.) Now I want…
Arpicheck
  • 1
  • 1
0
votes
0 answers

Copying TextReader/Writer to more places

I have console application that can turn winform with richtextbox. I want to redirect console and that richtextbox to each other. So whenever I write to them text will copy to another. My problem is when I'm waiting for ReadLine. I would like to…
Jara M
  • 125
  • 7
0
votes
2 answers

Extension Method from String to TextReader... how do I close the stream?

Is it possible to create an extension method similar to this? How should I handle Closing() the stream when finished? public static TextReader ToTextReader(this string XML) { StringReader sr = new StringReader(XML); return…
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
0
votes
1 answer

Import file into MATLAB cell array with space delimiter

I have a .asc file 'test.asc' which consists of lines with different length and content. my name is blalala This is my home and I live in here 12 13 10 is he he is my brother 12 13 14 How can I import the contents of the file into a MATLAB…
ryh12
  • 357
  • 7
  • 18
0
votes
1 answer

R replace character in string if occurs after location or more than once

I am trying to import interview transcriptions with textreadr, but it works by separating the text into two columns through locating a separator character (usually a colon). In transcriptions I have a colon occasionally appears in the body of the…
Gerard
  • 159
  • 1
  • 2
  • 11
0
votes
2 answers

Browse a file from my pc using web application in asp.net

I have a web application which I uploaded using IIS. I want the users using the application would be able to select a file located on their (the user) computer and read its contents. The code is: TextReader trs = new StreamReader(faFile.Value); …
Greg Oks
  • 2,700
  • 4
  • 35
  • 41
0
votes
4 answers

C# List or TextReader limit?

I'm trying to make a dictionary game, and I have a text file with about 100,000 words each on their own line. I have this code: words = new List(); Console.WriteLine("Please wait, compiling words list..."); TextReader tr = new…
Xenoprimate
  • 7,691
  • 15
  • 58
  • 95
0
votes
1 answer

Swift Array, TextFile?

I have a tableview that displays the following navigation from one tableview to another: Chapter 1 Topic 1 Heading 1 Sub Heading 1 Content 1 This is done using the following code: if var path =…
ScarletEnvy
  • 871
  • 1
  • 7
  • 14
0
votes
2 answers

Merging multiple text files into one and related problems

I'm using Windows 7 and Python 3.4. I have several multi-line text files (all in Persian) and I want to merge them into one under one condition: each line of the output file must contain the whole text of each input file. It means if there are nine…
Vynylyn
  • 172
  • 11
0
votes
3 answers

TextReader.Read() not returning correct integer?

So my method should in theory work, I'm just not getting my expected result back. I have a function that creates a new TextReader class, reads in a character (int) from my text file and adds it too a list. The textfile data looks like the following…
MattGarnett
  • 545
  • 3
  • 20
0
votes
7 answers

Quotes in tab-delimited file

I've got a simple application that opens a tab-delimited text file, and inserts that data into a database. I'm using this CSV reader to read the data: http://www.codeproject.com/KB/database/CsvReader.aspx And it is all working just fine! Now my…
royse41
  • 2,310
  • 4
  • 22
  • 29
0
votes
2 answers

Matlab - Help using text scan, how to ignore comments and header columns?

I need help using text scan. I am trying to read data that has the following format: # ---------------------------------- WARNING ---------------------------------------- # The data you have obtained from this automated U.S. Geological Survey…
Hooplator15
  • 1,540
  • 7
  • 31
  • 58
0
votes
1 answer

How to access to numbers from *.txt file in matlab?

I have a data.txt file like: 123 124 125 126 I want to compare these number against num My code is like this data= textread('data.txt','%d'); num = 125; if num == data b = 1; else b = 0; end but answer shows 0 (…
Binja
  • 121
  • 3
  • 3
  • 12