Questions tagged [file-writing]

This tag refers to the process of writing text or data to a file.

932 questions
-1
votes
4 answers

How to avoid the last comma while writing an integer array into a text file in python

I need to write an array of integers into a text file, but the formatted solution is adding the comma after each item and I'd like to avoid the last one. The code looks like this: with open(name, 'a+') as f: line = ['FOO ',…
TeilaRei
  • 577
  • 1
  • 6
  • 22
-1
votes
1 answer

How to write .properties file in Scala

I'm new to Scala & Java, trying to write .properties file using it but its giving errors: Ref: https://www.roseindia.net/java/example/java/core/write-properties-file-in-java.shtml Following is code: import java.io.File import…
J.K.A.
  • 7,272
  • 25
  • 94
  • 163
-1
votes
4 answers

How can i send a X amount of numbers to a txt file in Java?

I need to send X numbers to a txt file in Java and i have this: for(int count = 0; count< amount; count++){ text =text + array[count] + "\n"; try( PrintWriter out = new PrintWriter( "nums.txt" ) …
-1
votes
2 answers

Add ~ (tilde) in an Erlang string

I want to add ~ (tilde) in the string and write this string to a file. Eg. String = "~Hi~Welcome ~Presenting ~My~Problem~To~you Public ~L.", ile:write_file(WriteFileName, io_lib:fwrite(String,[])). Error received ** Reason for termination == **…
nikdange_me
  • 2,949
  • 2
  • 16
  • 24
-1
votes
2 answers

tree batch - looping output

I am trying to make a program that will give me the tree of my C: drive as a .txt file in batch. the program, when run, prints the following to the text file tree.txt: C:\>cd C:\ C:\>tree /a 1>>tree.txt C:\>cd C:\ C:\>tree /a 1>>tree.txt…
roger
  • 55
  • 1
  • 8
-1
votes
1 answer

Writing numbers into a file- check code

I'm taking my first ever CS class and I have an assignment due Friday. I just wanted someone to check my code and make sure it works/follows the directions. Instructions: Write a program that: 1) gets the name of a text file of numbers from the…
j.davis
  • 5
  • 4
-1
votes
2 answers

In Java, how do I overwrite a specific part of a line in a file?

I have a csv file thats formatted like this id,text. Here is an example: helloText,How are you goodbyeMessage,Some new text for a change errorMessage,Oops something went wrong Now lets say for example I want to edit the text part of goodbyeMessage…
cod3min3
  • 585
  • 1
  • 7
  • 23
-1
votes
1 answer

Adding blank lines in between

I have a function that exports a data table to a csv file. And there is a blank line added after every other line. This is the output to a txt file Assets|Profit Center|Plant|Asset Class|Depr Account|Cost Center|Inventory Number|Location|Cap…
-1
votes
1 answer

How to write csv file in apache spark using SparkR?

I am able to load data Successfully using following commands sc = sparkR.init(master = 'local', sparkPackages = 'com.databricks:spark-csv_2.11:1.4.0') sqlContext <- sparkRSQL.init(sc) ss <- read.df(sqlContext,…
-1
votes
1 answer

I am trying to advance to a new information each time someone signs up on my java application

So everytime someone clicks sign up on my program, I call a method that opens file and adds record. This is to open the file: try { l = new Formatter("chineses.txt"); System.out.println("Did create"); } catch (Exception e){ …
adoba yua
  • 41
  • 7
-1
votes
2 answers

Writing to file int converted to string

I just want simply write to file a string converted from int. But f.WriteString instead of number write a symbols from ASCII code table. I expected "noReport = 12320 nr3h = 105 nr2h = 162 nr1h = 38 ok = 16899" But instead got "noReport = 〠 nr3h…
nekto
  • 27
  • 2
  • 10
-1
votes
1 answer

Keeping file open in R

After executing write.csv the file connection is closed, because of which whenever I write data into the file, the old data is lost. But I want to keep writing data into the file without losing the old data. How do I do that? Thanks in advance.
-1
votes
2 answers

Using ofstream << operator

I am trying to write in a large file. My initial implementation was simply using std::cout and then redirecting the output to another file. I made another implementation where I use std::ofstream where I write directly to a file and when I compared…
stryker
  • 41
  • 5
-1
votes
1 answer

Python: Column index error with openpyxl

I have two lists which I want to write to a new xlsx file: list1=[1,2,3,4] list2=[A,B,C,D] I want list1 to be dumped to column A and list2 to column B: COLUMN A COLUMN B 1 A 2 B 3 C 4 D This is my…
FaCoffee
  • 7,609
  • 28
  • 99
  • 174
-1
votes
1 answer

Object has no attribute and will not write to .txt file

I am attempting to write data to a .txt file. The data that is being written are the random integers from the randrange function in the following code. I keep getting an error stating the object has no attribute when trying to write to the…
CUSE
  • 3
  • 3