iPhone App Con Sept 27 -- www.iphonedevcon.com
Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 8th, 2007, 04:49 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text Files

I have got a text file that contains the following information (delimited by “|”)

RBF|1.txt|04/01/2007 04:22:11
RBF|7.txt|04/01/2007 04:32:11
RBF|1.txt|02/01/2007 04:22:11
RBF|2.txt|03/01/2007 06:12:41
RAF|3.txt|07/01/2007 11:22:17
ROF|4.txt|05/01/2007 04:42:21
RBU|5.txt|04/01/2007 02:29:14


The first field contains the name of the folder, the second – the filename and the third – the creation date\time of the file.


I want to write this information into another file (ignoring files that are older than 7 days old from the date the application is run) in a format similar to this


-------------------------------------
|DIR|MO|TU|WE|TH|FR|SAT|SUN|
-------------------------------------
|RBF|0 |1 |1 |2 |0 |0 |0 |
-------------------------------------
|RAF|0 |0 |0 |0 |0 |0 |1 |
-------------------------------------
|ROF|0 |0 |0 |0 |1 |0 |0 |
-------------------------------------
|RBU|0 |0 |0 |1 |0 |0 |0 |
-------------------------------------

-------------------------------------
|TOT|0 |1 |1 |3 |1 |0 |1 |
-------------------------------------

TOTAL FILES 7


(There are 4 files for folder RBF, 1 created on Tuesday – 02/01/07, 1 created on Wednesday, 2 on Thursday and so on)


Please any help will be appreciated.

Thanks in advance




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old January 9th, 2007, 03:33 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No gurus?

:-(

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old January 9th, 2007, 10:14 AM
Registered User
 
Join Date: Dec 2006
Location: , , Germany.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to c010depunkk
Default

What kind of help do you want?
A finished app? Or do you have specific questions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old January 9th, 2007, 11:45 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not a guru, and this isn't a guru level problem.
How far have you gotten with this?
Have you written any pseudo code?
Do you know how to read and write from files?
Do you know how to use regular expressions?
Have you worked with ArrayLists?
You are describing a very basic problem that requires a knowledge of a few basic concepts. Rather than write your whole application, people who are willing to help usually want to help with a specific problem, not something as all-encompassing as this. So, what part of this are you actually having trouble with?

Woody Z
http://www.learntoprogramnow.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old January 12th, 2007, 04:24 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First thing for ease create a
struct sFInfo
{
 string sFolder;
 string sFileName;
 string sDate;
}
First thing is Open the file using a StreamTextReader or for that matter many other readers exist
After Opening the file successfully meaning check for null
Loop until End of File
ArrayList GetFileInfo(string sFName)
// sFName is the Text file which contains info you want to extract
{
string[] sArr;
sFInfo Fobj;
string sLine;
ArrayList alFileLst = new ArrayList();

while(!sr.EOF)
{
 sLine=sr.ReadLine();

 sArr= sLine.Split('|');
 FObj.sFolder=sArr[0];FObj.sFileName=sArr[1];
 FObj.sDate=sArr[2];
 alFileLst.Add(fo);
}
sr.Close();
sr=null
return alFileLst;
}

public void InfoWriter(ArrayList alFileList, string sCutoffDate)
{
In this method you read the arrayList one object at a time
 sDate is of importance within the structure as you loop through the
 ArrayList what you do is first separate the Date and time use the split with blank delimiter. (In the previous method I have used '|' as delimiter) then separate date into month and day and compare it use stringBuilder to create a format like you want. In case of a problem let me know )
All the best

I have got a text file that contains the following information (delimited by “|”)

RBF|1.txt|04/01/2007 04:22:11
RBF|7.txt|04/01/2007 04:32:11
RBF|1.txt|02/01/2007 04:22:11
RBF|2.txt|03/01/2007 06:12:41
RAF|3.txt|07/01/2007 11:22:17
ROF|4.txt|05/01/2007 04:42:21
RBU|5.txt|04/01/2007 02:29:14


The first field contains the name of the folder, the second – the filename and the third – the creation date\time of the file.


I want to write this information into another file (ignoring files that are older than 7 days old from the date the application is run) in a format similar to this


-------------------------------------
|DIR|MO|TU|WE|TH|FR|SAT|SUN|
-------------------------------------
|RBF|0 |1 |1 |2 |0 |0 |0 |
-------------------------------------
|RAF|0 |0 |0 |0 |0 |0 |1 |
-------------------------------------
|ROF|0 |0 |0 |0 |1 |0 |0 |
-------------------------------------
|RBU|0 |0 |0 |1 |0 |0 |0 |
-------------------------------------

-------------------------------------
|TOT|0 |1 |1 |3 |1 |0 |1 |
-------------------------------------

TOTAL FILES 7


(There are 4 files for folder RBF, 1 created on Tuesday – 02/01/07, 1 created on Wednesday, 2 on Thursday and so on)


Please any help will be appreciated.

Thanks in advance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old January 12th, 2007, 10:57 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by DriveU
 First thing for ease create a ...
DriveU: Your post is not very clear, and seems to be missing a lot of information. What exactly are you trying to show?

Woody Z
http://www.learntoprogramnow.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old January 12th, 2007, 12:01 PM
Wrox Author
Points: 13,210, Level: 49
Points: 13,210, Level: 49 Points: 13,210, Level: 49 Points: 13,210, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,102
Thanks: 1
Thanked 55 Times in 55 Posts
Send a message via AIM to dparsons
Default

I agree with woody, this is not a guru level problem and what you are trying to do is some what elementary (IMHO) so to reiterate woody, what are you trying to show and what exactly is your problem here. What does your code DO and what DOESNT it do?

-------------------------
I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old January 13th, 2007, 04:47 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My intent was not to write a complete program just give a direction one can take in a situation like this.
My solution will work for sure if done properly.
Maybe you have a better solution but my solution will work if implemented properly.
First thing is to separate information of interest with reference to the text file
Second thing is to perform a check to isolate data based on input parameters using StringBuilder build the format and as we go about doing this accumulate results and finally show the formatted strings.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old January 13th, 2007, 11:43 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by DriveU
Code:
First thing for ease create a 
struct sFInfo
{
 string sFolder;
 string sFileName;
 string sDate;
}
First thing is Open the file using a StreamTextReader or for that matter many other readers exist
After Opening the file successfully meaning check for null
Loop until End of File
ArrayList GetFileInfo(string sFName) 
// sFName is the Text file which contains info you want to extract
{
string[] sArr;
sFInfo Fobj;
string sLine;
ArrayList alFileLst = new ArrayList();

while(!sr.EOF)
{
 sLine=sr.ReadLine();
 
 sArr= sLine.Split('|');
 FObj.sFolder=sArr[0];FObj.sFileName=sArr[1];
 FObj.sDate=sArr[2];
 alFileLst.Add(fo);
}
sr.Close();
sr=null
return alFileLst;
}

public void InfoWriter(ArrayList alFileList, string sCutoffDate)
{
 My intent was not to write a complete program just give a direction one can take in a situation like this.
My solution will work for sure if done properly.
Maybe you have a better solution but my solution will work if implemented properly.
First thing is to separate information of interest with reference to the text file
Second thing is to perform a check to isolate data based on input parameters using StringBuilder build the format and as we go about doing this accumulate results and finally show the formatted strings.
Okay. Have fun.

Woody Z
http://www.learntoprogramnow.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare 2 Text Files mollem VBScript 4 August 21st, 2007 04:21 PM
Reading text files senthilreddy ASP.NET 2.0 Basics 1 May 22nd, 2007 08:32 AM
comparing Two text files rajkumar007 Classic ASP Basics 0 October 15th, 2005 07:22 AM
Comparing Two Text Files rajkumar007 Classic ASP Professional 0 October 14th, 2005 10:01 AM
Regarding " reading text files" spraveens Classic ASP Basics 1 October 14th, 2003 07:46 AM



All times are GMT -4. The time now is 03:42 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc