Questions tagged [io]

In computing, input/output, or I/O, refers to the communication between an information processing system (such as a computer) and the outside world (possibly a display, an information storage system, or another information processing system).

Filter by
Sorted by
Tagged with
4 votes
3 answers
11k views

Extracting text data from a file

Can I make this program that extracts text data from a file (size in MBs) even better performance-wise? I need to reduce the execution time. ...
7 votes
2 answers
2k views

Speed up CSV reading code (vector of doubles)

I am trying to read a single-columned CSV of doubles into Java with a string header. It is 11 megabytes and takes over 15 minutes to read, which is clearly ...
7 votes
1 answer
513 views

Node.js equivalent of cat -n or nl

To add line numbers to a file (via stdin to stdout) we can use cat -n or ...
  • 765
10 votes
3 answers
6k views

Writing .ppm images to a file

I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
7 votes
2 answers
251 views

Parsing store sales content from a text file

I asked this question yesterday, and now I have come up with this code: stock.h ...
4 votes
1 answer
386 views

Partial data reading implementation

I'm trying to learn Python and am working on a simple Tiled Map Format (.tmx) reader as practice. So as to not post too much code at once, I'm only publishing the ...
  • 765
5 votes
2 answers
21k views

Life, the Universe, and Everything [closed]

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input ...
user avatar
3 votes
2 answers
4k views

Reading in a file and performing string manipulation

In a question I answered I posted the following code: ...
user avatar
1 vote
1 answer
8k views

Java PrintWriter not printing data to file [closed]

This program is compiling just fine, and the variables and such seem to be passing through. However, when I open the text file there is no data. Can anyone point me in the right direction or nudge ...
  • 13
7 votes
2 answers
330 views

Reading three rows of six tab-separated numbers

I've just posted this solution in my review of @adrienlucca's question, which is to read three rows of six tab-separated doubles. ...
4 votes
1 answer
14k views

Writing integer to binary file

I wrote a python function that writes a integer to a file in binary form. But are there any ways that I can reduce the number of steps, is there a more efficient way to write a integer to a file? <...
  • 1,517
2 votes
1 answer
124 views

Better importation of variables from .txt file

I am an artist and a total beginner in C++. I would like to find a better method of importing my variables from a values.txt file, which may contain 18 values in ...
10 votes
7 answers
22k views

Reading Large Files in Java getting really slow

I am trying to read a large file ~200 MB (~300 million lines of text). I am using a relatively standard way of reading like: ...
  • 219
1 vote
2 answers
145 views

Floating-Point data input in Bash and C

I wrote a function that dynamically stores statistical data. I tried to clone the functionality of how I had originally written my solution in Bash. Is there perhaps something I could improve, or do ...
user avatar
3 votes
2 answers
273 views

Is this file I/O utility efficient or is there a lot of fat?

This is a class/method that manages files being written to and read from. I have a lot of code, and it grew as I tried to get it to work properly. Is there a better way to write this (i.e. trim the ...
  • 65
4 votes
3 answers
2k views

Simple I/O class for reading input data fast

I wrote a FastReader utility class that is supposed to read input fast. It's mostly aimed at parsing input files in competitive programming. How could I made this ...
  • 243
4 votes
2 answers
608 views

K&R 1-20 Converting tabs to spaces using idiomatic C

I'm learning C with K&R 2nd Ed. I just completed exercise 1-20 (which is the detab program). I was hoping to get some feedback on my work. I want to make ...
3 votes
2 answers
170 views

Attempting to efficiently compute the largest prime factor

I'm working on the third Euler problem and I've written a simple little function that returns the list of prime factors of a given number. The number for which I have to get all the factors is over 6 ...
2 votes
1 answer
199 views

Vocabulary trainer passing around too much IO/State

I've written a vocabulary trainer which does a lot of passing state around, as I have an ACID-database and a temporary state. In my experience with Haskell I've learnt that overusing ...
4 votes
4 answers
3k views

Reading a file into string in Java

I am quite new to Java, and I am trying to read a file into a string (or should I use byte arrays for this?). File can be anything, such as a text file or executable file etc. I will compress what I ...
  • 1,497
3 votes
1 answer
919 views

File I/O, SHA1 sum and compression

The function hash_blog is inspired by "how git stores its objects". It is supposed to take a String, append a header to it, ...
  • 1,497
5 votes
2 answers
952 views

Abstraction for an IO device

I have a C++ class which acts as an abstraction for an IO device which is controlled through file descriptors. As I am very new to C++, I would be glad if you can give me devastating feedback on ...
1 vote
1 answer
143 views

Verifying column and line counts

I have created this simple code: For the size of an array with 2 values (n and m), verify if ...
4 votes
1 answer
122 views

Detecting a combination of characters from input

Write a program that reads input up to # and reports the number of times that the sequence ei occurs. Is this a decent code? ...
  • 511
7 votes
1 answer
2k views

Mingw, wcout and locales

I've recently had to print some national symbols in windows console using Mingw and found, that I got nothing in the output, if I use wide strings. So, I studied ...
  • 224
6 votes
4 answers
8k views

C getline function

I was looking for a C function that reads lines of arbitrary length from a file. I didn't find anything absolutely portable and safe from buffer overflows, so I tried writing my own. Does it look ...
1 vote
2 answers
712 views

User prompts for entering quiz questions

I have two methods here that does the same thing: get the user input and validate them. If they enter a letter, the program will prompt them again to enter a number. |After that, if it's a number it ...
4 votes
3 answers
406 views

Simple text file I/O for book data

I wanted to learn how to work with file I/O properly and found an assignment in my college papers and decided to write it: ...
  • 489
4 votes
1 answer
9k views

Reading a .gz file

I am using Python 2.6.5 and am trying to find the fastest way to print out the contents of a .gz file. It's my understanding that prior to v2.5, zcat was much faster than gzip (see here)....I guess ...
user avatar
5 votes
2 answers
125 views

Ranking lines of a file according to number of occurrences

I recently dived into Ruby, so I want to improve this code. Is this good enough? ...
  • 53
11 votes
3 answers
6k views

Handle Java Process outputs without extra-threads

Usually, people would create two extra-threads in order to read the standard output and error respectively. However, the following code would allow to handle a Process outputs without those threads (...
  • 213
6 votes
2 answers
2k views

Slow web-scraping geolocator

How do I make my Python program faster? I have 3 suspects right now for it being so slow: Maybe my computer is just slow Maybe my Internet is too slow (sometimes my program has to download the html ...
5 votes
1 answer
2k views

File reader/writer using XPConnect, ActiveX, LiveConnect, Java, HTML5 file storage, or HTTP

I am writing a file writer/reader in JavaScript; I want it to work on local files. It tries to use Firefox's XpConnect, falls back on IE activeX, falls back on Java LiveConnect, falls back on a Java ...
  • 201
68 votes
2 answers
89k views

Redirecting subprocesses' output (stdout and stderr) to the logging module

I'm working on a Python script and I was searching for a method to redirect stdout and stderr of a subprocess to the logging ...
  • 781
3 votes
1 answer
4k views

Reading a large XML file and parsing necessary elements into MySQLdb

I have fair concept in a programming (learner) but not an expert to refactor code at the highest level. I am trying to read a huge (100MB-2GB) XML file and parse necessary element (attributes) from a ...
  • 31
1 vote
1 answer
163 views

Iterating through 128-byte records in a file

I need to read records from a flat file, where each 128 bytes constitutes a logical record. The calling module of this below reader does just the following. ...
  • 125
2 votes
2 answers
13k views

Reading file contents into a string

Option 1 - nice and simple ...
  • 347

1
6 7 8 9
10