Issues reading CSV file using OLEDB when filename have period - oledb

Issues reading CSV file using OLEDB when filename have period.
I have a code in C# that reads CSV File using OleDBProvider. It works perfect with filenames in regular format such as Budget.csv but failed when i renamed the file into Budget.DKK.csv or Budget.USD.csv
I throws this exception:
he Microsoft Jet database engine could not find the object 'Budget.DKK.csv'. Make sure the object exists and that you spell its name and the path name correctly.
I have no idea so far why is this happening.

If this thread is to be believed, then it is a known problem that won't be fixed. It mentions a work-around that allows the name to be forced into the old style 8.3 format.
And just as a random suggestion if you haven't tried it, maybe delimit the filename with brackets [filename.stuff.txt]. I doubt it is that simple, though.

Related

Parsing logs in Zabbix

i'm try to parse logs from windows folder in Zabbix, but everyday creates a new directory like "2022_03_15" and log files in her, how parse a new name directory?
log["C:\Windows\Temp\app\web\0\Log\YYYY_MM_DD\Application.log"]
The logrt item would come closest but reading https://www.zabbix.com/documentation/current/en/manual/config/items/itemtypes/zabbix_agent#supported-item-keys
It notes:
file_regexp - absolute path to file and the file name described by a regular expression. Note that only the file name is a regular expression
So, sadly, this is not possible yet.
You could try to work around this by first using a list to find the latest directory and use lld to create a new log item when that is needed. For these cases it is a pity that the file and location are part of the item key.

HttpContent.ReadAsMultipartAsync leaves behind a temporary file

I'm starting to go loopy on this one, which normally means I'm missing something obvious.
I have the following code in my .NET MVC controller:
var provider = new CustomMultipartFileStreamProvider("prefix", GetRepositoryTempFolder());
await request.Content.ReadAsMultipartAsync(provider);
The CustomMultipartFileStreamProvider inherits from MultipartFileStreamProvider, overrides the GetLocalFileName method and returns an appropriate file name for a given ContentDisposition header. The HttpContent handled is normally a PDF file and a small JSON settings component.
Everything works wonderfully as far as getting the parts parsed, extracted and saved in the expected location. However, after parsing I end up with a temporary file left over in my C:\Windows\Temp folder. The file has a randomly generated name (e.g. zf0hk2h4.ks2). It has the same size and creation date as the PDF portion parsed and saved by ReadAsMultipartAsync.
I believe ReadAsMultipartAsync uses this temporary file during parsing and leaves it behind. Has anyone else experienced this? Any way I can prevent ReadAsMultipartAsync from leaving this temporary file behind and clogging up the Windows temp folder?
My apologies; I was missing something. The file was being moved after processing. This is an invalid question; there is nothing wrong with ReadAsMultipartAsync.

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.

Deedle - what's the schema format for readCsv

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).

Delphi : how to check if a file exists (path over 255 characters)

I need to make my delphi app able to check if a file copied using Robocopy is there or not when its path exceeds 255 characters.
I have tried the usual "If FileExists(MyFile) then ... " but it always returns "false" even if the file is there.
I also tried to get the file's date but I get 1899/12/30 which can be considered as an empty date.
A File search does not return anything either.
Prefix the file name with \\?\ to enable extended-length path parsing. For example you would write
if FileExists('\\?\'+FileName) then
....
Note that this will only work if you are calling the Unicode versions of the Win32 API functions. So if you use a Unicode Delphi then this will do the job. Otherwise you'll have to roll your own version of FileExists that calls Unicode versions of the API functions.
These issues are discussed in great length over on MSDN: Naming Files, Paths, and Namespaces.

Resources