I am using Matlab to produce publishable graphs and have encountered problems with the print function for the first time despite having used it identically before. I can't figure out why it has stopped working.
When I run my script with
print(1,'-djpeg','My_Figure','-r300')
at the end, the results is a file that is a document type, not a jpeg.
Has anyone encountered this before or have any ideas why this might be happening?
As discussed within the comments->
One can try to append the file-extension:
print(1,'-djpeg','My_Figure.jpeg','-r300')
As this is documented different:
If filename does not include an extension, print appends an appropriate extension.
TMW: print
..it seems to depend on either the Matlab-Version or the OS Matlab is running on.
Related
OK, this may seem extremely silly but....
I use VSCode as a notepad and and terminal window. I created a myFunctions.ps1 file and placed all of my frequently used functions in that file. I call that file from my profile.ps1 so they are available.
I created a function that works properly. Even the predective tab-complete finds the function in the terminal window. All of my other functions format properly. For somer eason, it won't appear color-formatted (in green) like the other funcrtions do. Here is what it looks like. The top frame is a file called PowerShellCmdletLibrary.ps1. Basically a notepad of all my commonly used one liners and such. Notice in the text, my list of functions, all fuinctions are formatted Green except Replicate-AllDomainController
Does anyone know what that might be? Silly and petty I know but just a tad annoying (killing my OCD, lol)
Tony enter image description hereenter image description here
I have a script which uses gcsfs to write data to Google Cloud. Most of the time it works, but fairly regularly I get the following error:
ValueError: Non-final chunk write below min size.
This error seems to come from GCSFile._upload_chunk.
I can't really find anything in the docs that explains what might be going wrong here. I read this thread which suggests it might be related to how the data is committed (should I disable autocommit?) but I'm not sure it's entirely relevant. I read through the source of that function but that didn't help too much either. Would appreciate any guidance!
My code looks like this:
with gcs.open(file_path, mode='w') as f:
f.write('\n'.join(output_data))
output_data here is a list of strings. gcs is an instance of gcsfs.GCSFileSystem.
This issue apparently no longer happens in v0.7.0. Anyone facing it should upgrade.
Unfortunately this question may be a bit vague, I have a problem that I am finding difficult to describe, it is intermittent and I cannot reproduce it myself, I am just hoping that someone else has seen something like it before.
My application has quite a lot of text and ini files that get written when it closes down. Typically this would be in response to a Close event, but may also be triggered by a WM_ENDSESSION. Unfortunately at the moment I am not sure if both or only one of these events can result in the problem I am about to describe, because I have been unable to reproduce this problem myself.
The issue I have is that for some users some of the text and ini files end up being written as NULLs. The file sizes end up looking about right, but instead of text, every character is written as a x00. So instead of 500 bytes of regular ASCII text I end up with 500 x00's. I also have an application log file that can sometimes end up with nulls written to it also. However the logging of x00's to the log file does not necessarily correspond to the exact same time as x00's were written to the config files.
For my files I am using TmemIniFile or TstringList which means that ultimately a Tstrings.SaveToFile is being called for all of my config files.
sl:=TstringList.Create;
try
SourceList.GetSpecificSubset(sl);
AppLogLogLine('Commands: Saving Always Available list. List has '+inttostr(sl.Count)+' commands.');
sl.SaveToFile(fn);
finally
sl.Free;
end;
But then I also have instance where I would already have a TstringList in memory and I just call SaveToFile on it. For TmemIniFile the structure would look similar to above. In some instances I may have an outer loop to write multiple lists. Some of those will result in files being written correctly, some will be full of 00's.
EDIT: GetSpecificSubset is simply a function that will populate "sl" with a list of command names. I have "GetAllUsersCommands", "GetHiddenCommands", "GetAlwaysVisibleCommands" etc. Note that my log file also writes this kind of thing, as a check for how big those lists are:
16/10/2013 11:17:49 AM: Commands: Saving Any User list. List has 8 commands.
16/10/2013 11:17:49 AM: Commands: Saving Always Visible list. List has 17 commands.
16/10/2013 11:17:49 AM: Commands: Saving Always Hidden list. List has 2 commands.
I accidentally left the logging line out of the code above. So this log line is the last thing written before calling Tstrings.SaveToFile, and at that point it thinks it has data. Even if somehow each line of text were NULLs, I would still expect to see x13x10 in the files, but that is not happening.
Here's a screen cap from a HEX editor:
EDIT 2: I just realised I left off a very important piece of information. This is only intermittent. It works 99% of the time. When saving files at shutdown it might not even be all files. Even if I have a loop saving multiple similar files, some may work fine and others may fail.
I'm trying to use Kivy as a GUI for my python app, which needs to read a file from the filesystem.
However, in some cases the kivy filechooser read wrong path or nothing causing an IndexError while I'm trying to set the read path for a text of a textfield.
I use the default example for reading files learned from http://kivy.org/docs/api-kivy.uix.filechooser.html
The relevant part of my app is in this function, where an exception handling is added as a not a good approach to handle this :)
def load(self, path, filename):
'''
this will load the file and dismiss the dialog
'''
print "Loading file..."
print "filename:",filename
print "path:",path
try:
self.selected_file = filename[0]
self.file_text_input.text = self.selected_file
self.dismiss_popup()
except IndexError as ie:
print "Something made a boo-boo...try again"+str(ie)
self.dismiss_popup()
self.show_popup("ERROR","Somehow I couldn't load the file:\nCheck the permissions or move it to other place")
self.show_popup() is just a helper function, which shows a popup with the set function params.
The basic error is that filename[0] will throw an IndexError since it does not read the correct path.
I'm using Linux with python2.7, and somethimes when I select a file in my home folder, the filename variable stores nothing, while path variable stores misteriously a random folder, for instance, /media, /opt, etc.
Did anyone meet this issue?
I found out why it was handled uncorrectly.
All the failures are caused by Kivy's
FileChooserListView
, which enables to click on folders and files via a list, but it also makes it possible to have a littel '>' sign at the beginning of every list element, which are directories.
I realized that when I used these '>' signs, then I get wrong path, but if I always clicks on the directories' list elements then everything works fine.
However, that little '>' cannot be disabled (for now), so the best and fastest alternate solution is using
FileChooserIconView
instead!
Now everything is good :)
I am writing a program in Delphi which should get the date and time of the picture which was taken with photo cam and then it would rename the file to include the date+time it found.
So far i have achieved that by opening file as binary and searching for a special order of bytes. These bytes were then followed by the date and then time. So i've come to a problem. Actually few problems.
Because it reads the file 1 byte after another, reading a file is a slow process. If the date was found, it is usually at the start of file, it doesn't take long, however if 'special byte order' was not found, it will read the whole file. So my method is way too slow.
The special byte order may change in some pictures (i have no idea why) even if it was taken with the same camera. So my program sometimes fails to find the date in the file even though it is there.
Windows explorer has no problems finding date in all of the pictures, so i was thinking maybe there are some kind of special functions which could get me what i need?
How do i get the information i need from the picture so it works with all the formats?
Thanks
I think you only need to look at the EXIF information. http://en.wikipedia.org/wiki/Exif
There are some open source tools which accomplish that, but I don't know of anything Delphi specific. If you're not scared of Java, you can have a look at the source code of this open source project: http://sourceforge.net/projects/jexifviewer/ to see how they evaluate the date field.
You can then optimise your reader, to only look at the relevant area. You might want to keep in mind that the Endianness in Java is different to Delphi.
Jules is right about Exif data; you might want to try this Delphi library:
http://delphihaven.wordpress.com/ccr-exif/
This is an amazing site to view Exif data.
http://regex.info/exif.cgi
If it is a graphic file (as in your case), to open it with a dialog box, place a TOpenPictureDialog component on the form.
Also place the component TLabel, for displaying the date of creation of the file.
In the button's place the following code:
if OpenPictureDialog1.Execute then Label1.Caption := DateTimeToStr(FileDateToDateTime(FileAge(OpenPictureDialog1.FileName));
In order to open jpeg and png files in the code, in the line uses you need to add the name of the two libraries, JPEG, PNGImage.
If you have the full address of your file, you can write the code above instead of the code above:
Label1.Caption := DateTimeToStr(FileDateToDateTime(FileAge('full address to file')));
If you only need the date, without the file creation time, then instead of the DateTimeToStr command, use the DateToStr command.