last day (15 days later) » 

4:18 PM
0
Q: string is missing the last 2 characters when writing to a CSV file

ChrisI have a CSV file that I needed to manipulate, manipulating it went fine, until it writes to a CSV file then it is missing the final characters of the string. I have no idea why because when I loop through the list of strings that it shows the last 2 characters, but when I open up the CSV file th...

 
0100...The times are in military time, so I changed it around so its normal time.
@JoelFan, I open up the sheet and its opened with excel.
@AlexK., I understand what you are saying but when I iterate through the list the am and pm is there, but disappears when written to a CSV. It needs to be a CSV because its for a phone system.
@JoelFan, needs to open as a csv file. The phone system requires it to be that way
@JoelFan, I just did as you suggested and it shows up properly in NotePad. So, since it looks right in notepad, how do I get it to look right in the CSV? I have to save it as a CSV file
 
@Chris You need to get it in a format that Excel will recognize as a date. By the way, I think you're discovering some of the limitations of the CSV file approach. If your goal is actually to generate a file that can be opened in Excel, then you should build an actual .xlsx file using a library such as Open Office XML SDK or EPPlus.
 
@mason, I don't think that I need Excel to recognize it as datetime. I don't think it matters because the phone system will load the CSV file and read it from there. I have an idea...
My idea didn't work, I decided to cast the finishedline as a string, but when excel looks at it it keeps looking at it as a DateTime
 
@Chris Is the goal to view it in Excel? Then you'll need to make sure it is in a format that Excel recognizes as a date. Is your goal to load it into a 3rd party system? Then check the documentation for that system to see what format it expects the data in.
 
@mason, its for a third party system. I did look at the documentation and how I have it in the text file is the way its supposed to be. The third party system is voicent. And it insists that it be a CSV file
 
4:18 PM
@Chris Then I'm afraid I don't understand what your problem is.
 
Hi mason, sorry to message you but I didn't want to clog up the thread
 
Please explain what the problem is.
 
the problem is that the have an EMR system and they pull the data from the EMR system. The EMR system creates a CSV like...John, 123-456-7890, 12/1/2014, 1000
So I had to manipulate that csv file and write it out as john, 123-456-7890, 12/1/2014 10:00 am
No when I open it as a text file, the am and pm is there, but when I open it (with excel) the datetime is being recognized as a datetime and leaves out the am and pm
Voicent, insists that it be a CSV file
 
Why does it matter what it looks like in Excel? How is this file going to be used?
 
That's the thing, I am not sure if it matters what it looks like in Excel, I am not sure if Voicent opens it that way or just reads it as is. I do need to have the extension as CSV, so I unsure how it gets read. Voicent is a software that places calls for reminders to patients or whomever
the more I think about it, that you may be right a CSV file is a CSV file no matter how its read. So it might not matter how it looks in excel
 
4:25 PM
If it's an automated system, it does not matter what it looks like in Excel. When you view the file with a text editor, you're seeing a truer representation of what's in the file. Excel makes guesses at what data format you have, and can be configured in different ways which obscures what the data actually is in the file. So as long as this file is going to be used by a computer, then all that matters is having the data in a format that their system is going to understand.
 
cool, thanks for your help if you wanna post what you said as an answer then i'll accept it. If you know anything about regex, I'll be putting up another question incase you want to get in on that next question. Either way thanks
 
I'm not very good with Regex. But I can tell you that Regex is often used when it shouldn't be.
 
Yea, I need to use for a scrape that I am doing, I know its the regex and I am not familiar with it. I have a ViewState and ViewStateGenerator and I cant get it to distinguish between the two
 
Are you scraping a webpage?
 
yes, At first they wanted the whole site scraped, then changed their mind to narrow down the search
The main thing about narrowing down the search means I won't get timeouts
 
4:31 PM
Regex is probably going to be the wrong approach. Instead, you should use the HTMLAgilityPack
Regex is meant for regular languages. It doesn't work well with HTML.
 
I actually am using that to rip out the tables off the pages...This is the code for the regex .... var viewState = Regex.Match(responsedata, "__VIEWSTATE.+?value=\"(.+?)\"", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].ToString();
I agree, regex is not the best thing to use for html
 
Alright. Well I can't help you further than that because I suck at regex.
 
Lol, its all good, thanks for sticking with me on the CSV question
 

last day (15 days later) »