Closed

File Manipulation

This project was awarded to amsak for $3 USD / hour.

Get free quotes for a project like this
Employer working
Awarded to:
Project Budget
$2-$5 USD / hour
Total Bids
22
Project Description

Program needs to run on Windows 7 Pro: Perl/Cygin/shell/C++ are all fine. Although prefer something readable for easy changes.

I have a remote server constantly streaming CSV data to a port. Something that a netcat can print. I used "nc [url removed, login to view] 5200 > [url removed, login to view] to get the data" High level, it has a 20-30 line header (which can be discarded see my attached file), and then constantly streams readings.

Date Time, Roughness
2013-05-24 20:47:30,[url removed, login to view]
2013-05-24 20:47:30,[url removed, login to view]
2013-05-24 20:47:30,[url removed, login to view]
2013-05-24 20:47:30,[url removed, login to view]
2013-05-24 20:47:31,[url removed, login to view]
2013-05-24 20:47:31,[url removed, login to view]
2013-05-24 20:47:31,[url removed, login to view]
2013-05-24 20:47:31,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:40,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]
2013-05-24 20:47:43,[url removed, login to view]

There will be about 8 readings/lines in about a second. Sometimes as few as 4. sometimes as many as 10. But normally around 8 readings per part. Then a pause of about 2 seconds The normally 8 readings in about a second/part , then a pause of seconds, etc.

Things I need:

1) Don't need any information from the header, it can be skipped
2) A new file for each part. Start a new file whenever:
a) 2 seconds pass without a new reading
b) a [url removed, login to view] record is received (don't want the [url removed, login to view] in a file)
c) 10 readings are received
3) File name should be "Production YYYY-MM-DD [url removed, login to view]" Basically, the filename should be "Production + the date" making sure it's unique
4) If under 4 readings, skip the file
5) Output format is a | delimited file named "Product 2013-05-24 2013-05-24 20:47:31" using the date format above. Contents are:

START|Production|Production
DATA|Surf_Fin_Meas_1|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_2|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_3|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_4|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_5|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_6|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_7|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_8|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_MAX|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_MIN|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_AVG|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
DATA|Surf_Fin_Meas_RANGE|[url removed, login to view]|[url removed, login to view]|0|[url removed, login to view]|2|3|Surface_Finish
END|[url removed, login to view]

Notes:
1) Line (Start) 1 is static (use as is)
2) Line 2-9(13) the readings from the input file.
a) Field 1 is the word DATA
b) Field 2 is the field name (Surf_Fin_Meas(1--10)
c) Field 3 is the ROUGHNESS measurement from the input file
d) The remaining fields are static
3) The next 4 lines are MAX, MIN, AVG, and RANGE of the roughness
4) The last line is END with the DATE in windows format. The date should be last date of the readings in the input file.
Windows format is:
Integer = Int((Year - 1901) * [url removed, login to view]) + 366 + DayOfYear
Fraction = (Seconds + (60 * Minutes) + (3600 * Hours)) / 86400
Date = Integer + Fraction
Where DayOfYear for Jan 1 is 1 and Hours for 12:34 AM is 0
e.g. 01-25-1995|14:15:07
Integer = (1995-1901) * [url removed, login to view] + 366 + 25
Integer = [url removed, login to view] + 366 + 25
Integer = 34724
Fraction = (7 + (60 * 15) + (3600 * 14))/86400
Fraction = (907 + 50400)/86400
Fraction = [url removed, login to view]
Date = 34724 + .59383
Date = [url removed, login to view]

=======================
I'll have a number of upcoming projects. I've paid up to $3000 for a project in the past.

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online