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
6
votes
1answer
55 views

Get only intended input from user through the console

I finally worked out all of the bugs in this bit of code. I'm pretty proud of it and I wanted to give it to all of you so that you could have it if you wanted it for any console programs that you make....
2
votes
1answer
105 views

Input-reading library for Node.JS

Recently I have been busy with nodejs and I thought to create something like this Java input library, so I started with some rough code like below: ...
4
votes
2answers
2k views

Rust function to read the first line of a file, strip leading hashes and whitespace

I’m writing a Rust function for getting a title based on the first line of a file. The files are written in Markdown, and the first line should be a heading that starts with one or more hashes, ...
6
votes
0answers
106 views

Positioning a file pointer with MPI I/O

This toy code uses MPI I/O to read from a binary file. It goes through reading: an ASCII header the first 10 doubles from an array of 100 ...
2
votes
2answers
113 views

Optimized Int Reader

I am new in Golang, and decided to create a function that could cater to my needs of reading an integer from stdin. I need the function to be as efficient and fast ...
3
votes
1answer
77 views

Read file contents to string safely

I've just started to teach myself Rust. I've written the following code to read a text file and store the contents in a String. Is this the typical way of doing ...
1
vote
1answer
4k views

Sum over selected numpy.ndarray column and write to a file

I am trying to write the sum of selected NumPy array column and write to a file. The following code snippet is working fine: ...
8
votes
3answers
5k views

Invoicing Program Python

This is my invoicing program I made for myself to keep track of purchases people made from me. (Yes I know eBay does this for me but I wanted to see what I could make.) Basically it can search the ...
5
votes
1answer
165 views

Printing fizzy lines

Challenge Given a test case print out a FizzBuzz Series. Specifications The first argument is a path to a file. Each line includes a test case. Each test case is comprised of three spaced ...
9
votes
2answers
721 views

Reading binary files in XTF format

I have a few thousand binary files that have corresponding structs in them, followed by any number of bytes (this exact number of bytes is given in one of the fields in the structs). I read in data ...
2
votes
1answer
51 views

Updating certain values in text file

So I need to update some certain values within text file based on actual values there. Any advice on making it more effective or just readable is appreciated. Example text file: ...
5
votes
1answer
4k views

Printing JUnit test results in file by changing and using the 'out' static variable of 'System' class

I'm building a framework for comparing files (in my own way) using JUnit. All test cases have been packaged in a JAR which is ran independently using a .bat file I ...
1
vote
1answer
604 views

Reading a file chunk by chunk in QT 4.3.3

I have following code in QT in ...
6
votes
1answer
6k views

Counting newlines in a file

I've started to go through Node tutorials on nodeschool.io, and the second assignment was to write a program that will count the number of newlines in a file and print it out. My solution looks like ...
2
votes
0answers
3k views

Golang: reading and writing files in parallel

I am trying to read a big file line by line, inspect and cleanse each row and write to either of two output files depending on the outcome. I am using channels for this. I am still quite new to this ...
3
votes
3answers
1k views

Extracting the longest line from standard input

I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own ...
1
vote
1answer
488 views

Composing IO and Async in haskell

Whether based on MVar or TVar, async implementation are always based on operation on some underlying monad IO and STM. Making Async a monad on its own, as in F# async computation builder, if done in ...
3
votes
2answers
284 views

Exercise 1-22 from K and R: line folding

I'm currently learning C with K&R, i'm right now in the exercise 1-22, but it's a little... hard to understand (at least for me). It says: Write a program to "fold" long input lines into two or ...
2
votes
0answers
57 views

Practicing rogue-wave I/O

What I'm doing: Searching in current directory for a set of files. Filtering the set. Searching through the filtered set of files for a specific line sequence. Write to an output file that line along ...
7
votes
2answers
261 views

Higher performance reading shorts from binary file

I just got rejected at the tech interview of a job application. They gave me the following exercise for me to complete: They gave me a binary file with 10 million pairs of 16-bit signed integers. ...
13
votes
2answers
380 views

Python 3 decompression routine 10x slower than C# equivalent

I'm relatively new to Python 3, especially IO programming, writing a Blender add-on to import model data. The model data is available in a custom compression, and I originally wrote code in C# to ...
7
votes
4answers
590 views

Custom user input function

The program consists of 3 files: demo.c, mylib.c and mylib.h. The code is heavily commented. ...
2
votes
1answer
1k views

Read output from a subprocess executed by Python

I've written these 2 methods and I'm wondering if the 2nd method, which uses yield is more efficient or if I'm using yield wrong. Can someone refactor the 2nd method to make it more efficient for ...
1
vote
0answers
162 views

Customized streambuffer for C++ istream

Basically I implement a traditional file-descriptor-based streambuffer for istream operations. The implementation overrides the ...
0
votes
1answer
953 views

Reading from text files in C/C++ [closed]

I'm writing a program that has to check which are the two largest three digit numbers that are missing from a text file. I'm writing this in C++ and I'm trying to solve the mystery in a ...
2
votes
0answers
90 views

Write to terminal and buffer

...
3
votes
3answers
131 views

Write the running time to file without capturing the program's output

I want to run an application and write (append) its processing time into a file. Also, I want to see the stdout and stderr output on the shell, but don't want to write it in a file. After running the ...
2
votes
2answers
4k views

Write into the same CSV file multiple times

I implemented an OutputWriterService.class to write content in the same file multiple times. The writeToCsvFile method is ...
11
votes
1answer
174 views

Recreation of cat in C

I have a school project to create a program that works the same as the Linux cat. The code works, but I just need find out where I can Improve it or handle errors. ...
4
votes
1answer
62 views

Prompt system from reading a text file

I worked starting from basic example code from an exercise in chapter 10 of Java: A Beginner's Guide, Sixth Edition, the code in the exercise was not very good and I wanted to improve upon it and make ...
5
votes
1answer
94 views

Transferring data from one file stream to another

I am currently reading Clean Code and for fun and profit, I intended to refactor some of the Java Tutorials and since I wanted to improve my Exception handling, the Byte Stream one with its lots of ...
5
votes
1answer
192 views

K&R 1-20 Solution

I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are ...
1
vote
1answer
577 views

Using Pexpect for communication between multiple programs via I/O

I have a Python script that runs three compiled programs and makes them communicate via standard I/O. This is my first time using pexpect. My program runs very ...
6
votes
2answers
8k views

Prompting for a positive integer and validating user input in Java

I'm just starting out with Java, and trying to make a method to get a positive integer input from the console. My currently working implementation is this: ...
6
votes
1answer
2k views

8086/DOS assembly keyboard I=input, data loss in registers

I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an ...
3
votes
1answer
321 views

Reading arbitrarily long lines from a file that is redirected as input

So I have a file with a list of dates that are to be redirected as input to stdin and what the program does is it searches for valid dates, appends them to the output file and then appends all the ...
4
votes
2answers
4k views

Multiprocess, multithreaded read write on a single file

I've got a job to create a library that would be able to support multithreaded and multi process read and write to a single file. On that single file we would store C# models in an array in JSON ...
4
votes
2answers
378 views

Reading file into structure

At the time I'm trying to read a quite big file into a C program for later user. The file size is in the range of 800 megabytes containing around 20 million lines of data of the following format: ...
4
votes
2answers
198 views

K&R C Exercise 1-14: Histogram of the frequency of types of characters

This is for K&R C Exercise 1-14: basically asking to create a program that prints a histogram of the frequency of types of characters. This is done with very basic C functions/knowledge as covered ...
1
vote
1answer
2k views

Reading input fast in Java for competitive programming

I have been solving problems on Timus Online Judge. In the beginning, I didn't worry much about I/O operations, so I just took some code from the internet and focused more on the logic. But after ...
3
votes
2answers
65 views

Constraining stdin in Python, v2.0

Rags, again. This is the rewrite of Read stdin like a dictator. From that post: All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only ...
2
votes
1answer
149 views

Vigenère cipher as an IO filter

I implemented a Vigenere encoding and decoding class. Ideally, the program should be able to take any abritrary file, read into an array of byte, and decode it. ...
5
votes
1answer
119 views

Implementing cat function in Julia

I wanted to implement the cat function in Julia and I ran a few test cases but I am not sure if I am missing anything: ...
1
vote
0answers
73 views

Reading content of directory for each HTTP request

I have a piece of code written in node and I wanted to know if I am in the right direction. Basically I have a site where the homepage lists 6 vehicle cards. Every time the page is requested I do the ...
4
votes
1answer
135 views

Reading entire contents of file at a given java.no.file.Path into a String

What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file. I'm wanting the ...
8
votes
4answers
8k views

Creating a unique file name in C#

I find that I am often writing files where the names either: Need to be incremented (rather than overwriting a file that already exists in the directory with the same name) Need to be timestamped ...
4
votes
1answer
46 views

Memory mapped classpath HttpServlet

I have a single page application where the resources sit on the classpath. Any request for a resource that doesn't exist should redirect to the index.html page. ...
8
votes
6answers
590 views

K&R 1-23 Remove all C comments

From K&R exercise 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't nest. My solution, ...
15
votes
2answers
872 views

K&R 1-21 write an “entab” program

From K&R exercise 1-21, Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When ...
20
votes
3answers
1k views

“Welcome to Buzzway Subs!”

There were a few recent questions which had a challenge like this: The subway shop provides catering for meetings and other events. All sandwich platters are $40 each. Cookie platters are $20 ...