How to modify a CSV file in Xcode Project Navigator - swift

I'm currently working with a team that updates different rows and columns of a CSV file that lives locally in the app. The issue is that they have resorted to copying and pasting the entire CSV file into a new CSV file, modifying data and copying the edited CSV file and pasting it back into the project. I was curious if anyone had any suggestions on how they can edit the CSV file in Xcode without the complicated mess of copying and pasting.
P.S. Quick Look would prove useful if you could edit the CSV file in this mode.

One simple approach could be to have a reference to the file instead of a hard copy, this way each time you edit the file it should update on the project automatically. Look at this link for more refs: http://www.thomashanning.com/xcode-groups-folder-references/

This answer will only work if you have software such as Microsoft Excel on your computer.
In the Project Navigator, right click the csv file and select open with external editor. This will allow for Xcode to open the csv file using Excel. Modify any data as needed and save your work on Excel. Your csv file in Xcode will now reflect your changes made in Excel.

Related

Powershell write to a CSV while it's open

I have a process that will be running essentially 24/7. It will be writing data to a CSV but I want to be able to read that CSV periodically. The problem is that it seems like Export-Csv fails even when the file is opened in read only mode.
The CSV file in question is already marked as Read-Only so all writes I make to it in my script are using the force switch. This works fine but the second I open the file in excel (or even view it's properties in Windows Explorer) the script starts erroring out.
All I want to do is be able to do is write to a CSV with export-csv while also allowing that csv to be opened by excel in read only mode. Is this possible or do I need to come up with some method where I create a secondary copy of the file for viewing purposes?
The Office suite has the tendency to lock files it opens (I'm making this assumption because you're working with a CSV). If you open your file in notepad.exe, the problem you're experiencing will no longer happen.

Swift: Parse .strings file to .csv file using Command Line Tool

I need to convert my Localizable.strings file to .csv file.
Can i do it using SwiftGen API? What it the best solution for that?
This question could probably use a bit of clarification, Birdy. For example: how often do you need to do this and do you need to do this automatically (as part of building a project) or manually & only occasionally.
Anyways, to answer, the SwiftGen documentation on top of it's repo says nothing about CSV formats, so that's not going to help you.
.strings files are in the format of key=value, so you could simply open the .strings file in your favorite text editor (e.g. Xcode!) and you could use find/replace to replace "=" with a tab character. There's also a couple other solutions found in this very related question.
I faced with the same problem and all the tools I tried did not work. Some for example most tools/technics did not take in to account the comments from the developer that are included in the strings file.
So I ended up developing my own tool csv2strings, that converts Apple's strings file to and from csv files.
Just downloaded it and run:
swift run csv2strings Localizable2.strings

Opening Simulink models created in newer versions of MATLAB

I have received a simulink model from one of my students, but as he is using a newer version of MATLAB (8.6) than the one i have installed (8.5) i get an error when i try to open it.
How can i open it without asking him to save in an older format?
If you have a .slx file that you need to convert, the process is a little different. Using a tool like 7Zip, open the .slx file (a .slx is really just a disguised .zip file) so you can edit it without extracting all the files. Go into the "metadata" folder. Edit each of the .xml files in there and change the tags for <cp:version> and <matlabVersion>. Save each and have 7Zip update the archive for you.
Like the other responder said though, if you used any part of your model uses features inherent to the newer version, those components will be broken.
It was actaully quite simple.
I opened the .mdl file in a text editor and search/replaced
8.6->8.5
and 2015b->2015a
Sometimes when doing this an error occurs when opening a model for the first time. After saving it the first time and reopening it this error dissapears.
It should however be noted that if the model contains a new component or if the functionality of a component has been changed this method will not work.
Sigurd

Scratch: How do I produce an ascii text program listing?

My nine year old son is applying to participate in a programming contest. Any language is allowed, and he wants to use Scratch. But the application requires an ascii text listing of a program to solve a specified preliminary problem. They will not accept a PNG screenshot, or Scratch's binary format. So how does he get an ascii listing of his program? If it is impossible (as I suspect) then I will just read his program and retype it into an ascii editor.
You have a few options here.
If you're using Scratch 1.4, you can save a text-only project summary. Shift-click the File menu, then Write project Summary.
This functionality is coming soon (hopefully) to Scratch 2.0. UPDATE: It has been added.
You can also get a text-based representation of all the blocks using the Scratchblocks generator.
Or, you can save the 2.0 project as myproject.sb2, rename to myproject.zip, unpack the ZIP, and take the project.json file.
Unfortunately, none of these methods can easily be imported back into Scratch.
http://scratchblocks.github.io will convert your project into scratchblocks format. It is exactly what you are looking for.
You can download and edit the json script for the Scratch project. It can then be uploaded to replace the existing project. (This is also a great way to back-up and deploy projects)
From the "See Inside" screen, File->Download to your computer.
Rename the file to have a ".zip" extension instead of just ".sb2".
Unzip the file to edit the "project.json" file.
Edit the json code as desired.
Reassemble the zip file
Remove the ".zip" extension. (Back to ".sb2")
Update the Scratch project by going to the original project and selecting File->Upload from your computer.

Can I search Netbeans' local history?

In one of the previous versions of one of my file in a Netbeans project I wrote code that I later removed, and now I want to retrieve it. However now I can't find it when I manually go to previous versions, as I have many versions in the local history of this file, and I don;t remember when exactly I wrote this code.
Is there a way to run a search on the local history of this file?
I saw in this answer that the local history is kept in this path
<HOME>/.netbeans/<NB_VERSION>/var/filehistory where HOME is my user home and NB_VERSION is the version of NetBeans (e.g. 7.0).
I tried running AgentRansack on that directory, but to no avail.
I recently had to solve this problem and figured it out. Netbeans stores local history files in your user directory as mentioned above. Inside that folder are numbered directories. It's pretty easy to guess which one you need based on the modification date of the folder (if you know when you last looked at it, so that doesn't help you much). In side the numbered folders is another folder with a hashed name, and inside of that folder is a set of files: a data file, and numbered files. The data file can be read with a binary file reader, and if viewed in ascii mode will show the filename that this history belongs to. The numbered files are actually zip files and they have full versions of the file in them. Just unzip those and open with a text editor if they are plain text files.
Hope this helps you out, but I realize its probably too late now. I had to figure this out because I had opened a remote file with netbeans (a file that was not associated with a project), and couldn't get back into the Local History because the file didn't have a project. However I could see it in the Local history by reading the data file, and I just guessed that the other files were zipped by the fact that they started with "PK" in the binary viewer. Once I put it all together I was home free.