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 8982115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:30:24+00:00 2026-06-15T20:30:24+00:00

Can anyone help me to create a csv file from List, my scenario is,

  • 0

Can anyone help me to create a csv file from List, my scenario is, i have a multi dimensional values like below in a List

List<string[]> lst = new List<string[]>();
lst= csv1.ToList();

lst contains the values like,

lst[0] = {string[53]}
lst[1] = {string[53]}
lst[2] = {string[53]}
lst[3] = {string[53]}
lst[4] = {string[53]}

and string[53] contains the values like

lst[0]
    string[0] = "abc"
    string[1] = "def"
    string[2] = "ghi"
    string[3] = "jkl"
    string[4] = "mno"
    ...
lst[1]
    string[0] = "123"
    string[1] = "456"
    string[2] = "789"
    string[3] = "10"
    string[4] = "11"
    ...

I just wanted to write this multi-dimensional list to csv file as each item in lst[] to rows in csv and each item in string[] to columns such that the final output in my csv is

abc,def,ghi,jkl,mno
123,456,789,10,11

Any help would be really appreciated.

  • 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-06-15T20:30:24+00:00Added an answer on June 15, 2026 at 8:30 pm

    At the simplest level, not handling quoting / escaping / multi-line CSV issues, then just loop; maybe something like:

        using (var file = File.CreateText(path))
        {
            foreach(var arr in lst)
            {
               file.WriteLine(string.Join(",", arr));
            }
        }
    

    or a tiny bit more efficient (no intermediary string):

        using (var file = File.CreateText(path))
        {
            foreach (var arr in lst)
            {
                if (String.IsNullOrEmpty(arr)) continue;
                file.Write(arr[0]);
                for(int i = 1 ; i < arr.Length ; i++)
                {
                    file.Write(',');
                    file.Write(arr[i]);
                }
                file.WriteLine();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me create an android layout like the image below. It has
I created the below function to pass memory from a csv file to create
Can anyone help me how to create a JSON Object from the database? This
Can anyone help me create a batch file? Basically, my goal is to create
I'm new here. Can anyone help me for how create a form like this
I have to create a vertical menu using clutter in C. Can anyone help
I want to create a .dbf file. Can anyone help me out how to
Can anyone help with some problems I have. I am trying to create an
I need to create HTML pop-up menu using Perl. Can anyone help me?
Can anyone help? I have a created a relationship between my Reservation(prim key) and

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.