我们最近收到了一堆带制表符分隔符的文件.
我们在sql server数据库中导入它们时遇到了困难.
发送文件的供应商也发送了以下代码供我们用于将文件从制表符转换为逗号分隔符.
如何在visual studio中使用此文件.
我曾多次使用visual studio,但我还没有将它用于像这样的单个文件.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace TabToComma
{
class Program
{
static void Main(string[] args)
{
StreamReader sr;
StreamWriter sw;
sr = new StreamReader(@"c:\input.txt");
sw = new StreamWriter(@"c:\output.txt");
string nextline;
string replacedline;
while (sr.Peek() >= 0)
{
nextline = sr.ReadLine();
replacedline = nextline.Replace('\t',','); // replace each tab in line with a comma
sw.WriteLine(replacedline);
}
sr.Close();
sw.Close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
或者,如果有人知道如何使用vbscript完成同样的事情,请指出我正确的方向.
非常感谢提前
| 归档时间: |
|
| 查看次数: |
110 次 |
| 最近记录: |