Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6673345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:37:01+00:00 2026-05-26T03:37:01+00:00

Task 1: Read each row from one csv file into one seprate txt file.

  • 0

Task 1: Read each row from one csv file into one seprate txt file.

Task 2: Reverse: in one folder, read text from each txt file and put into a row in a single csv. So, read all txt files into one csv file.

How would you do this? Would Java or Python be good to get this task done in very quickly?

Update:
For Java, there are already some quite useful libraries you can use, for example opencsv or javacsv. But better have a look at wikipedia about csv if no knowledge on csv. And this post tells you all the possibilities in Java.


Note: Due to the simplicity of the question, some one pre-assume this is a homework. I hereby declare it is not.

More background: I am working on my own experiments on machine learning and setting up a large scale test set. I need crawl, scrape and file type transfer as the basic utility for the experiment. Building a lot of things by myself for now, and suddenly want to learn Python due to some recent discoveries and get the feeling Python is more concise than Java for many parsing and file handling situations. Hence got this question.

I just want to save time for both you and me by getting to the gist without stating the not-so-related background. And my questions is more about the second question “Java vs Python”. Because I run into few lines of code of Python using some csv library (? not sure, that’s why I asked), but just do not know how to use Python. That are all the reasons why I got this question. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:37:01+00:00Added an answer on May 26, 2026 at 3:37 am

    From what you write there is little need on using something specific for CSV files. In particular for Task 1, this is a pure data I/O operation on text files. In Python for instance:

    for i,l in enumerate(open(the_file)):
       f = open('new_file_%i.csv' % i, 'w')
       f.write(l)
       f.close()
    

    For Task 2, if you can guarantee that each file has the same structure (same number of fields per row) it is again a pure data I/O operation:

    # glob files
    files = glob('file_*.csv')
    target = open('combined.csv', 'w')
    for f in files:
       target.write(open(f).read())
       target.write(new_line_speparator_for_your_platform)
    target.close()
    

    Whether you do this in Java or Python depends on the availability on the target system and your personal preference only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a common, simple task: Read configuration settings from a configuration file, save the
Overview of My Situation: My task is to read strings from a file, and
Consider the task: Read a polygon from a KML file using library A Intersect
I had this task to read a file, store each character in a dict
I basically have an application that has, say 5 threads, which each read from
I want to read a text file and store its contents in an array
I am trying to execute a certain task where i am required to read
Simple task like make AJAX request , pass one parameter and return result, can
I have a task to create a crossword, a specific one. All the answers
I have a CSV file with many rows in which I need to update/replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.