I'm looking for a way to automatically do a find and replace after I have imported data from a CSV file. The date data in my CSV file has a time stamp that I do not want to use. Yes, I can do it manually but would like to automate it if possible.
The data in the left column is what I want to change to match what is in the right column.
Sample Data
Thanks.
Related
I collect various data in time plots. If I copy the timeplot data and then paste it into Excel, the number format is often wrong. For example, I often get a date like Aug 94 instead of the actual number from the TimePlot. Unfortunately, I can't easily format this date into a number either, since the formatted number does not match the actual number from the timeplot. If I format the date in the same format as the number above and below, then I get the number 34547. However, this number does not correspond to the actual number of the TimePlot. Anyone know how I can prevent this problem?
You can only solve this on the Excel side, AnyLogic provides the raw data for you. Excel then interprets stuff. You can test it by pasting the chart raw data into a txt or csv file.
So either fix your Excel settings or paste into a csv, then into an xlsx.
Or better still: Do not manually paste at all. Instead, write your model results into the AnyLogic database and export to Excel from there: this takes away a lot of the pain for you. Check the example models to learn how to do that.
This is not AnyLogic question, rather an Excel & computer formatting problem. One way of resolving this is changing computer's date and time settings.
Another way is to save your output at txt file in AnyLogic. Replace all . with ,. Then open empty Excel, select Text format for the columns. Copy-paste from the txt file.
In Excel there are a few options
when you paste use paste as text only option
But this does not always work as Excel will still try to format the stuff for you
Use the Paste Special option and then choose text
Also possible this will not work, based on your Excel settings.
Paste using the text import wizard
(This works for me without fail)
On step 2 choose tab delimited
On step 3 choose Column format as text for every column (you need to select them in the little diagram below)
You will then see the data exactly as it came from AnyLogic. See the example below where I purposefully imported some text which has something that Excel will think is a date. You will now be able to see what in your data made Excel thing your data needed to be formatted the way it is and then you can fix it. (post a new question if you struggle with this conversion)
But as noted by other answers first prize is to write all the important data to external files. But I know that even I sometimes want to export data from a chart and review it in Excel. Option 3 works for me everytime
I have question
There are excel data like this
input file
More than 500 person
I wanna convert data to csv
expected csv result
The data age is not 100% the second row, some may be third row. Name can be duplicate data.
I’m really confused. Can i use excel feature to do this or any way like coding?
I upload file : https://ufile.io/rxe1l
Add name, age, add etc as column in excel and export as .csv.
In your Excel workbook, switch to the File tab, and then click Save As. Alternatively, you can press F12 to open the same Save As dialog.
In the Save as type box, choose to save your Excel file as CSV (Comma delimited).
Please simply follow this link conversation excel into csv
I have a lot of CSV files which I created by gathering data from a website. The CSV files all have the same type of format as they are just different sets of data with the same headers. For example:
School,Carleton University
School Facts,
SchoolName,Carleton University
Location,"Ottawa, ON"
SchoolType,University
Language,English
Student Count,"24,554 Students"
Student Type,Full-time Undergraduate
Would be a standard CSV I have where other CSVs would just contain a different entry for things like SchoolName, Location etc.
What I wanted to do was open one of these files and then format it a certain way (ie. highlight certain things like SchoolName row, or things like School Facts to make the document easier to see). I was wondering if its possible I can do it for one and the just import other CSV's and they would automatically be the same way? If it is how do I do it or is there another way I can go about handling the data from the CSV to make it presentable?
Thank you, not sure if I am asking this right as I am new to excel and using CSV's in general.
Open your csv, record a new macro in a personal workbook, format your csv, stop recording.
Make sure to select the whole column when you format so if your next csv has more line, the format will still work. Save your macro, and you should be able to run it everytime you open a new file.
You could import it into a tab and have another tab that maps to all the fields in the tab you import to, and make the 2nd tab formatted however you like.
Also check out conditional formatting for things like highlighting things that meet certain criteria.
In excel I can open up a csv file using external data sources, and then chose to get data from text. This takes me through a set of steps to import the file. This works great, but I have a need to automate this process as many of these documents will need to be converted over time.
Is there a way to run a similar process as a script? I'm a complete newbie in this space.
You can run this command in a script:
csv2odf yourdata.csv yourtemplate.xlsx output.xlsx
You would need to get csv2odf and Python and create a template like this:
Insert column titles with the same number of columns as the csv.
Add one sample row of data. You can add formatting if you want.
Save the template as xlsx.
I am looking to merge about 15 different excel files to create one dataset. I know the variables in the coding are the same in each file. The problem is that the start rows for all of the data is inconsistent for each xls. Is there a way to use proc import and identify specific rows to import for each file?
Thanks!
Assuming you are using DBMS=EXCEL, you have the RANGE option available to you:
proc import file="myfile.xlsx" out=mydataset dbms=excel replace;
range="'Sheet1$A1:Z1000'";
run;
Obviously change Sheet1, A1, and Z1000 to match what you need.
This manual page contains further information on other DBMS options, including for DBMS=XLS.