
StreamReader inputReader = new StreamReader(TextFile.FileContent) Using (StreamWriter outputWriter = new StreamWriter(File.Create(strExcelOutputFilename))) string strUploadFileName = "C:/Documents and Settings/rhlim/My Documents/Visual Studio 2005/WebSites/SoD/UploadFiles/" + ("yyyyMMddHHmmss") + strExtension Generate the file name to save the text file. If (strExtension != ".TXT" & strExtension!=".txt") String strExtension = Path.GetExtension(strFileName) String strFileName = Server.HtmlEncode(TextFile.FileName) Get the name of the Excel spreadsheet. that the FileUpload control contains a file. Before attempting to import the file, verify String strExcelOutputFilename = "C:/Documents and Settings/rhlim/My Documents/" + ("yyyyMMddHHmmss") + xlExtension Protected void SaveAsExcelBtn_Click(object sender, EventArgs e) Protected void Page_Load(object sender, EventArgs e) Below is my code: public partial class TextToExcel : .Page Once you run the code in Python (adjusted to your paths), you’ll get the CSV file at your specified location.I am using VS2005 C# and im trying to convert a pipe delimited text file to excel workbook format. Read_file.to_csv (r'C:\Users\Ron\Desktop\Test\New_Products.csv', index=None) Read_file = pd.read_csv (r'C:\Users\Ron\Desktop\Test\Product_List.txt') So this is the complete code to convert the text file to CSV for our example (note that you’ll need to modify the paths to reflect the location where the files are stored on your computer): import pandas as pd

Read_file.to_csv (r'Path where the CSV will be saved\File name.csv', index=None) Read_file = pd.read_csv (r'Path where the Text file is stored\File name.txt')

C:\Users\Ron\Desktop\Test\New_Products.csv Step 4: Convert the text file to CSV using Pythonįinally, you may use the template below in order to facilitate the conversion of your text file to CSV: import pandas as pd
