Deedle - what's the schema format for readCsv - f#

I was using Deedle in F# to read a txt file (no header) to data frame, and cannot find any example about how to specify the schema.
let df= Frame.ReadCsv(datafile, separators="\t", hasHeaders=false, schema=schema)
I tried to give a string with names separated by ',', but seems don't work.
let schema = #"name, age, address";
I did some search on the doc, but only find following - don't know where I can find the info. :(
schema - A string that specifies CSV schema. See the documentation
for information about the schema format.

The schema format is the same as in the CSV type provider in F# Data.
The only problem (quite important!) is that the Deedle library had a bug where it completely ignores the schema parameter, so no matter what you provide, it would be ignored.
I just submitted a pull request that fixes the bug and also includes some examples (in the form of unit tests). See the pull request here (and click on "Files changed" to see the samples).
If you do not want to wait for a new release, just get the code from my GitHub fork and build it using build.cmd in the root (run this for the first time to restore packages). The complete build requires local installation of R (because it builds R plugin too), but it should build Deedle.dll and then fail... (After the first run of build.cmd, you can just use Deedle.sln solution).

Related

Any documentation for the XML format of TF.EXE's vc status command?

I am writing a script which will act on modified files in my TFVC (Microsoft Team Foundation Version Control) workspace. I'm invoking tf.exe vc status /format:xml to get the list of changes, but I need to exclude deletes. Is the XML format it returns documented? I know I want to filter on the chg attribute of the PendingChange elements, and I could discover the value by deleting a file and seeing what it returns, but I suspect there may be other values that I should check for as well. It would be much nicer to work off a documented canonical list rather than fixing the script each time it fails on a new value or combination I hadn't seen before. Does the documentation or a schema definition exist? (Neither of the two search engines I use led me to any.)
It seems there is no such documentation available yet. The pending change types using mostly are as below:
I've tested the chg attribute of the PendingChange element in the XML file for the pending change type above, you may reference it:
PendingChange chg="Encoding Branch"
PendingChange chg="Undelete"
PendingChange chg="Rename"
PendingChange chg="Edit"
PendingChange chg="Add Edit Encoding"
PendingChange chg="Edit Rollback"
PendingChange chg="Delete"
PendingChange chg="Edit Encoding"
I found the pending change types come from the enumeration Microsoft.TeamFoundation.VersionControl.Client.ChangeType which is documented in the TFVC client API documentation here: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/bb170193%28v%3dvs.120%29. Although it's not documentation of the XML format, it is the canonical list of the possible values.
As a side note, I ended up not being able to use the XML output for my script since it does not include new files (unless they have been specifically added, which in my scenario they are not) which I needed for my script. (Since I didn't have time to code to the TFVC client library, I parsed the output from tf vc status /format:brief.)

Machine parseable error messages

(From https://groups.google.com/d/msg/bazel-discuss/cIBIP-Oyzzw/caesbhdEAAAJ)
What is the recommended way for rules to export information about failures such that downstream tools can include them in UIs.
Example use case:
I ran bazel test //my:target, and one of the actions for //my:target fails because there is an unknown variable "usrname" in my/target.foo at line 7 column 10. It would also like to report that "username" is a valid variable and this is a possible misspelling. And thus wants to suggest an addition of an "e" character.
One way I have thought to do this is to have a separate file that my action produces //my:target.errors that is in a separate output group and have it write machine parseable data there in addition to human readable data on stdout.
I can then find all of these files and parse the data in them in downstream tools.
Is there any prior work on this, or does everything just try to parse the human readable output?
I recommend running the error checkers as extra actions.
I don't think Bazel currently has hooks for custom error handlers like you describe. Please consider opening a feature request: https://github.com/bazelbuild/bazel/issues/new

Cache XMLProvider generated model(s)

Using XMLProvider from the FSharp.Data package like:
type internal MyProvider = XmlProvider<Sample = "C:\test.xml">
The test.xml file contains a total of 151,838 lines which makes up 15 types.
Working in the same project as the type declaration MyProvider is a pain, as it seems the XmlProvider is triggered everytime I hit CTRL+SPACE (Edit.CompleteWord) - and therefore regenerates all the models, which can take up to 10sec.
Is there any known work around, or setting to cache the generated models from XmlProvider?
I'm afraid F# Data does not currently have any caching mechanism for the inferred schema. It sounds like something that should not be too hard to add - if anyone is interested in contributing, please open an issue on GitHub to start the discussion!
My recommendation for the time being would be to try to simplify the sample XML, so that it is shorter and contains just a few representative records of all the different kinds.

Get localized name other channel

I get the version number of the firefox from the applications.ini.
Then I hardcoded that between date #### and #### v35 is release. So now based on this and the current date and version from applications.ini I figure out the channel of other builds.
But now I want to get the localized name of the channel.
So for example I'm using beta channel and from this build I want to get the localized name of "Nightly" in chineese, so it has the chineese characters, and word for nightly in chineese. Can this also be obtained from the applications.ini? Is [App] -> Name localized in applications.ini?
This is the applications.ini method: https://ask.mozilla.org/question/705/detect-if-auroranightlybetanormal-and-get-paths/ (credits to #paa)
EDIT
i discovered this file: OS.Path.join(Services.dirsvc.get('XREExeF', Ci.nsIFile).parent.path, 'defaults', 'pref', 'channel-prefs.js')
its contents is the following:
//#line 2 "c:\builds\moz2_slave\rel-m-beta-w32_bld-00000000000\build\browser\app\profile\channel-prefs.js"
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pref("app.update.channel", "beta");
Is this a reliable check? Does this channel-prefs.js file exist for all builds as soon as they are installed?
Is this a reliable check?
Not really. There used to be channel switcher add-ons, and in theory the user can change this pref (although at the moment this is not sufficient to really switch the channel I think).
Does this channel-prefs.js file exist for all builds as soon as they are installed?
Yes, for now. But this is an implementation detail. There is no guarantee that the file won't be moved or renamed later, or merged with another file.
Can this also be obtained from the applications.ini?
The localized name? I didn't even know there was one... I thought it was called e.g. "Nightly" in all locales like it was a (product) name. But yeah, it is theoretically possible to localize that string. It is not available from the ini file, though.
I wouldn't poke in application.ini anyway, and instead just use Services.appinfo.defaultUpdateChannel
But now I want to get the localized name of the channel.
Since you're in a running Firefox instance already (judging from your OS.File code), you should use the string bundle service to load chrome://branding/locale/brand.properties and get the brandShortName or brandFullName string from there.

Lua - My documents path and file creation date

I'm planning to do a program with Lua that will first of all read specific files
and get information from those files. So my first question is whats the "my documents" path name? I have searched a lot of places, but I'm unable to find anything. My second question is how can I use the first four letters of a file name to see which one is the newest made?
Finding the files in "my documents" then find the newest created file and read it.
The reading part shouldn't be a problem, but navigating to "my documents" and finding the newest created file in a folder.
For your first question, depends how robust you want your script to be. You could use Lua's builtin os.getenv() to get a variety of environment vars related to user, such as USERNAME, USERPROFILE, HOMEDRIVE, HOMEPATH. Example:
username = os.getenv('USERNAME')
dir = 'C:\\users\\' .. username .. '\\Documents'
For the second question, there is no builtin mechanism in Windows to have the file creation or modification timestamp as part of the filename. You could read the creation or modification timestamp, via a C extension you create or using an existing Lua library like lfs. Or you could read the contents of a folder and parse the filenames if they were named according to the pattern you mention. Again there is nothing built into Lua to do this, you would either use os.execute() or lfs or, again, your own C extension module, or combinations of these.

Resources