|
Duncan Edwards Jones wrote: the columns of the rows are being put together in a string variable
That was my guess as well. It could have been easily handled by the other programmer...he knew it was a problem, hence the phone call to me stating that my import isn't working properly with their new file format.
C'mon man, the thing won't even open properly in Excel!
"Go forth into the source" - Neal Morse
|
|
|
|
|
Yeah - I think at this stage I have seen every type of craziness in CSV files - including columns containing the separator in the data with no quotes at all.
|
|
|
|
|
If it won't open in Excel, its because Microsoft didn't plan accordingly.
Isn't that the general thought process? Microsoft should account for everything?
|
|
|
|
|
Oh, it will open in Excel...column A contains comma separated values!
My comment was that it didn't open properly.
"Go forth into the source" - Neal Morse
|
|
|
|
|
|
kmoorevs wrote: (generally a sign of formatted numbers)
Wait, what?
Quoted text is supposed to be string data, particularly when there are commas in it, not a way of saying 'it's a number, Jim, but not as we know it'.
They are really killing that CSV format. I feel your pain.
|
|
|
|
|
Fueled By Caffeine wrote: Quoted text is supposed to be string data
Yes, sorry I misquoted! Yes, what I meant to say was that we apply special treatment to quoted fields/text where a number is expected but never expected each line to be double-quoted.
It basically caused my parsing routine to behave in an unexpected way...not too difficult to fix once you see it coming.
"Go forth into the source" - Neal Morse
|
|
|
|
|
Doesn't that simply import each row as a single field per row? Seems to me your code is working.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
John Simmons / outlaw programmer wrote: Seems to me your code is working.
Getting one field where multiple fields are expected was a problem.
The original logic was just to remove any commas found between double-quotes. Doing this with the single field (of comma delimited values) just pushed everything together and made a mess.
A little added logic to detect if the entire line is wrapped fixed everything. Easy.
The point was that sometimes you just have to take what the client gives you and make it work...that and how lazy (or stupid) the client's dev was for not understanding what the problem was.
"Go forth into the source" - Neal Morse
|
|
|
|
|
So, going through MDN's documented HTTP response status codes I ran into this nugget in the 400's:
418 I'm a teapot
The server refuses the attempt to brew coffee with a teapot.
I can appreciate the sentiment.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Wikipedia has slightly more information:
This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol[^], and is not expected to be implemented by actual HTTP servers.
But with stories like this[^] getting more common, it can't be long until this is used in a real project.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
In other news, Mark Nottingham lives at home with Mom and his friends are like his sense of humour.
Nonexistent.
veni bibi saltavi
|
|
|
|
|
One of the teams where I work are called the 418's and they are named after this response.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
|
Love it!
I also enjoy how every time you click the teapot, it triggers an analytics callback.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hah! I should return this code to malicious/blacklisted IP's.
|
|
|
|
|
I've been thinking that it would be perfect for malformed user input.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
no I didn't...
..a much younger me wrote this piece of "code" which is bad in so many ways I don't even want to count them:
CString StrEncode(CString str, bool decode)
{
CString map = "S)y³T<.zÖ?tp3~o`u^F}G\\0D_K:>1µ5&|ßJ§ö $E!rÜq-I]W%=Xü´Yl/(78A#dHm@BvQLM'*Pc+2Äxf,ghCnsä;6UO{9a[b4Ne²wjkViRZ°";
short len = map.GetLength();
short add = decode ? len : 0;
short mul = decode ? -1 : 1;
short off = str.GetLength() % len;
CString out;
for(short i=0; i<str.GetLength(); i++)
{
if(map.Find(str.GetAt(i)) == -1)
out += str.GetAt(i);
else
out += map.GetAt((map.Find(str.GetAt(i)) + add + ((i + off) * mul) % len) % len);
}
return out;
} The only good thing about it is that it served its purpose of weakly obfuscating strings.
Please absolve me
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Sascha Lefèvre wrote: Please absolve me
To be forgiven, you must obtain an abacus from ebay and perform the computations of your algorithm by hand with nothing but the abacus.
|
|
|
|
|
I'll possibly carry this burden forever then
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I fixed it for you : FTFY - rewrote it in C# so you can run it in LINQPad[^]
I'll put this out on GitHub as soon as possible.
void Main()
{
Console.WriteLine(StrEncode("Here it is", true));
Console.WriteLine(StrEncode("´;µsDUkGäB", false));
}
String StrEncode(String str, bool decode)
{
String map = "S)y³T<.zÖ?tp3~o`u^F}G\\0D_K:>1µ5&|ßJ§ö $E!rÜq-I]W%=Xü´Yl/(78A#dHm@BvQLM'*Pc+2Äxf,ghCnsä;6UO{9a[b4Ne²wjkViRZ°";
int len = map.Length;
int add = decode ? len : 0;
int mul = decode ? -1 : 1;
int off = str.Length % len;
String outMsg = String.Empty;
for(int i=0; i<str.Length; i++)
{
if(!map.Contains(str[i]))
outMsg += str[i];
else
{
outMsg += map[(map.IndexOf(str[i]) + add + ((i + off) * mul) % len) % len];
}
}
return outMsg;
}
Here's the resulting output:
´;µsDUkGäB
Here it is
|
|
|
|
|
I can see you caught fire - maybe we can achieve great things together
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Yes, this could be bigger than base64 encoding which is far easier to use.
People using base64 are just lazy.
|
|
|
|
|
Pfft... Dictionaries are so much faster than string searches...
|
|
|
|