- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
paging @remy:
[image]Admin
Foo, beat me to it by mere seconds.
Admin
:bow:
and for once we have an article without a "Frist" comment!
..... DAMMIT!
Admin
This looks like something you would have to do if you couldn't persist a variable/object past each executable line... Oh wait.
Admin
.csv
echo "AccountExpirationDate*accountExpires*AccountLockoutTime*AccountNotDelegated*...
It looks like this is an asterisk-separated file. Shouldn't that make the extension
.asv
?Second, is there actually any script which can
importrestore this junk to Active Directory?Admin
csv is pretty universally accepted to be "delimiter-separated" nowadays instead of merely "comma-separated"
Wikipedia
Admin
Excel should be able to...if not, worst case is
Admin
Wikipedia
What I meant is that if this is a backup script, do they actually have a restore script as well? Having your account data in Excel will do you much good...
I have edited my original post.
Admin
Okay? Somehow that makes everything in the article completely and totally untrue? Or are you just being obstinate?
It will? No problem then, right?
Admin
Since you're incorrigible, here's a little evidence (sadly, not many doctoral theses have been done on whether people type the star or the comma or the bar in between values on their computers) that may convince you that maybe that crazy thing is true because it's so hard to believe anyways:
https://technet.microsoft.com/en-us/library/hh849932.aspx
Microsoft's PowerShell has an
Export-Csv
cmdlet which both allows you to set the delimiter manually or set it based on the system's culture, because NOT EVERY COUNTRY IS THE SAME.It gets the current culture's
TextInfo.ListSeparator
property, which isn't the same in every country around the world! (.NET does this, too)Another piece is that when importing text data into excel, it allows you to select a delimiter, and several are offered (pipe, comma, semicolon, and colon, among others) by default, although you can specify your own.
Admin
No backup procedure is ok until a restoration has been performed: in the meantime, it is just a waste of I/O.
Admin
Actually it's asterix separated storage so the extension should be .ass
:-P
Admin
Sometimes you really wonder whether the
creatorsperpetrators of these sorts of scripts ever think “maybe there's a better way to do this”. :facepalm:Admin
My point exactly.
Admin
That's TRWTF. Why you would want to have your data format depend on the country of origin is beyond me.
Admin
We'll get right on that, right after the US switches to SI units.
Admin
I've had this problem before. I'm sure there is some standard command line export or serialisation that can be used.
CSV doesn't have an official standards but for most simple purposes people will:
I've seen CSVs with separators, weird delimiters and padding because for some reason people think they have to be human readable when they don't. You use a converter for that or import into a spreadsheet.
Admin
As someone who does BASH/Unix and PowerShell scripting regularly this looks to me like a Unix guy trying to program PowerShell without learning how it works first. The problem here is not PowerShell, the problem is whoever wrote that mess. This can be done in 4 lines:
Admin
Actually the worst is that people use , blindly as a separator.
I usually prefer ; as it is rare that that could show up in data other than text.
Especially since some country-settings specify to use , as the decimal point (we do in Denmark) causing all manner of fun when some rows contain floating point values (other places it is used as a 1000 - separator which also can result in hilarity).....
Admin
Yazeran the worst is when people keep changing delimiters to avoid collisions instead of using an escape sequence.
Admin
Admin
the kraw and the lac....or however you spell them....
-shudder-
i18n is hard guyz!
Admin
If you've got control over what is being generated, tabs are a really good choice. They virtually never turn up in structured data or user input. It's only once you get into source code and full documents that they start to make a natural appearance.
The evil option is to use a NUL. :smiling_imp:
Admin
Or
\b
Admin
Doesn't the Windows API use null-delimited lists in some places?
Admin
I don't know, but it wouldn't surprise me. The POSIX API certainly does (and tries to hide the fact from you).
Admin
TRWTF is failure to use ISO8601 dates, amirite?
Admin
That's what we do - our WTF is what we use for empty fields, cause somebody vetoed trailing tabs.
Admin
Two places I know of:
GetEnvironmentStrings()
returns a list of null-terminated strings, terminated by an empty string (== two null characters).lpstrFilter
member of theOPENFILENAME
structure (usedGetOpenFileName()
andGetSaveFileName()
for displaying file chooser dialogs) is a list of null-terminated strings, again terminated by an empty string (== two null characters)Admin
ISO8601 is the one true date format.
RFC2550 is tollerated as an alternate date format.
ALL OTHERS ARE HERITICS AND MUST DIE!*
(* The date formats i mean. the people who use them are salvageable with mild to moderate reeducation and do not need to be killed)
Admin
That's a pretty generous definition of "line" you have there...
Admin
Ooohhh I have to remember that one Evil cackling laughter
On the issue of tabs as separator, then yes they work, but there is one caveat, and that is if some bozo edits your scv file and somehow deletes one of the tabs and then replaces it with the requisite number of spaces for the 'data to line up as it should'...
Admin
Orders Received!
Admin
https://wiki.guildwars2.com/images/6/66/Quaggan.jpg
Admin
I once dealt with CSV files where the delimiter was the string SPLIT_CHAR. At least in never needed to be escaped in data.
That definitely did not help make the CSV human readable.Admin
E_NOT_CHARACTER
Admin
4 lines, huh?
What is the format of a double-null-terminated string with no strings? [Old New Thing]
Spoiler: [spoiler]
'\0'
[/spoiler]Admin
Agreed. I didn't do it, and it was a bit beyond the scope of my project to clean up the mess (which would have eliminated the CSV files entirely — 1. Parse data from files. 2. Write data to CSV file. 3. Discard parsed data. 4. Read and parse CSV file. 5. Use data. — steps 2, 3, and 4 entirely superfluous, and originally 2 was very, very slow).
Admin
Wait, did you need random access on a CSV file for some reason? Why not just do the transformation while you read the file instead of writing it out and reading it back in?Whoops, misread that explanation.Admin
Did someone say "country"?
United States, Canada, Mexico, Panama, Haiti, Jamaica, Peru, Republic Dominican, Cuba, Carribbean, Greenland, El Salvador, too. Puerto Rico, Colombia, Venezuela, Honduras, Guyana, and still, Guatemala, Bolivia, then Argentina, And Ecuador, Chile, Brazil. Costa Rica, Belize, Nicaragua, Bermuda, Bahamas, Tobago, San Juan, Paraguay, Uruguay, Suriname, And French Guiana, Barbados, and Guam. Music* Norway, and Sweden, and Iceland, and Finland, And Germany, now in one piece, Switzerland, Austria, Czechoslovakia, Italy, Turkey, and Greece. Poland, Romania, Scotland, Albania, Ireland, Russia, Oman, Bulgaria, Saudi Arabia, Hungary, Cyprus, Iraq, and Iran. There's Syria, Lebanon, Israel, Jordan, Both Yemens, Kuwait, and Bahrain, The Netherlands, Luxembourg, Belgium, and Portugal, France, England, Denmark, and Spain. Music* music
India, Pakistan, Burma, Afghanistan, Thailand, Nepal, and Bhutan, Kampuchea, Malaysia, then Bangladesh (Asia), And China, Korea, Japan. Mongolia, Laos, and Tibet, Indonesia, The Philippine Islands, Taiwan, Sri Lanka, New Guinea, Sumatra, New Zealand, Then Borneo, and Vietnam. Tunisia, Morocco, Uganda, Angola, Zimbabwe, Djibouti, Botswana, Mozambique, Zambia, Swaziland, Gambia, Guinea, Algeria, Ghana. Even More Music
Burundi, Lesotho, then Malawi, Togo, The Spanish Sahara is gone, Niger, Nigeria, Chad, and Liberia, Egypt, Benin, and Gabon. Tanzania, Somalia, Kenya, and Mali, Sierra Leone, and Algiers, Dahomey, Namibia, Senegal, Libya, Cameroon, Congo, Zaire. Ethiopia, Guinea-Bissau, Madagascar, Rwanda, Mayore, and Cayman, Hong Kong, Abu Dhabi, Qatar, Yugoslavia... Crete, Mauritania, then Transylviania, Monaco, Liechtenstein, Malta, and Palestine, Fiji, Australia, Sudan!
Admin
Admin
There's also the multi-string registry entry.
Admin
How about ASCII 0x1E (record separator) or 0x1F (unit separator)? Everyone loves unprintable control characters in their text files, right?
I've never used Apple Numbers, but I suspect if you tried launching it from the console after setting the environment variable
LC_ALL
to something likeen_US.utf-8
, it would probably work (and justLC_NUMERIC
may also be sufficient, too). That would save you the trouble of having to change a global system setting, but you'd still have to re-launch Numbers twice.Admin
Because different countries have different "standards"? Are you an idiot, or were you born with a partially-developed brain? TRWTF is why not every country speaks English and uses the Metric system and the US Dollar. :trolleybus:
Admin
I'm pretty sure this is a "yes," as the human brain is typically not fully developed until around age 20.
Admin
Well, I manually wrapped the line for space reasons. It's long because of the select statement. Really, if you wanted to be able to read it back into an object later you'd use Export-Csv rather than ConvertTo-Csv, and you'd skip the select, the original codetastrophy above is saving EVERY attribute, even those that aren't defined, which is actually unnecessary except that the same coder probably had an equally awful solution for reading that mess back in.
Example of a shorter 4-line solution:
Admin
See my reply to Spectre
Admin
+,
Admin
Here's your :pendant:.
Admin
What the heck, ONE(*) line, with no guarantee that this is even a wise way to try to backup your AD accounts.
*) Assumes you have the AD module loaded, if not you'll need another line to load it.