![]() |
| ||
| Problem with arrays and list hey friends i am reading a csv file and i have to read a specifice coloumn form the file and that coloumn contains date and i have to read the date first and then keep a validation that if the dates in the file are between some dates then the program will read data from another file . The csv file contains a header and that creates a problem while reading the first row the file the file data is like this: start_date_time,ani,dialed_digits,actual_dur,rounded_dur_secs,cost "03/01/2008 00:05:57",629172162448,"923455755684",2,2,0.002800 "03/01/2008 00:15:56",79279906564,"79278454880",51,60,0.135000 "03/01/2008 00:16:51",4166143724,"92922202502",188,188,0.256900 "03/01/2008 00:23:13",07956563557,"925871021085",1020,1020,1.393400 "03/01/2008 00:38:13",639262060046,"923084230440",1,1,0.001400 "03/01/2008 00:47:02",--------------,"92945623075",124,124,0.169400 "03/01/2008 01:08:14",7187696383,"92946725834",457,457,0.624300 The code of mine goes here static void Main(string[] args) |
| ||
| Re: Problem with arrays and list If you managed to read the date column data so put them in array 2- remove the ' " ' from each string(date) using string.Remove("\""); method 3- convert the string to date and compare the two dates DateTime.Compare(date1, date2); 4- based on value returns from DateTime.Comapre -1, 0 or 1 go through execution some codes... |
| ||
| Re: Problem with arrays and list hi ramy i have written the code like this have a look at it: this prints the date in perfect manner now what i want is that if the array contains the date value between 03/01/2008 (mmddyyyy) to 03/09/2008 then the program should print the whole records which come in between these dates. so can you help me please.. |
| ||
| Re: Problem with arrays and list Option #1 private void button2_Click(object sender, EventArgs e) Option #2 private void button1_Click(object sender, EventArgs e) Both examples create a new file with only the desired dates. Option #1 simply copys the file into a new file where the date is in the desired range . Option #2 is a little fancier, where it uses a DataTable to get the data, and allows you to write it out at one time. The datatable approach opens the door to all kinds of filtering, sorting, write out as XML, whatever you can do with a data table. // Jerry |
| All times are GMT -4. The time now is 4:45 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC