簡體   English   中英

如何從csv文件讀取數據並將數據寫入新csv文件中的某些行

[英]How to read a data from a csv file and write that data to certain rows in a new csv file

我想讀取一個文件,然后寫入另一個文件中的某些列

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;



namespace ConsoleApplication2
{
class Program
{
    static void Main(string[] args)
    {


        try
        {
            using (StreamWriter sw = new StreamWriter("AEJoinerDataTemplate.csv"))
            // using streamwriter to write to a text file
            using (StreamReader sr = new StreamReader("AutoEnrolment.csv"))
            // using streamreader to read a text file 
            {
                while ((txtline = sr.ReadLine()) != null)
                {

一種非常靈活的方法是先將記錄放入對象,然后將要輸出到新文件的對象的那些字段寫入。

例如,您可以使用下面的庫從文件讀取對象並將對象寫入文件。

文件助手

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM