MS access convert convert rows to columns - ms-access-2007

I'm working on a database in MS Access 2007 for a flight simulator, and I need to pivot the data - that is, convert the rows to columns.
It's difficult to explain, so let me show what my problem is.
The data I have to start with looks like this:
Waypoint Lat Lon previous/next minimim-alt airwayName
00MKK 22.528056 -156.170961 BITTA 12 R464
00MKK 22.528056 -156.170961 CKH99 12 R464
03SML 25.61 30.635278 57SML 195 L321
03SML 25.61 30.635278 AST 85 W8
03SML 25.61 30.635278 KHG 85 W8
03SML 25.61 30.635278 KUNAK 195 L321
I need the data to look like this:
Waypoint Lat Lon AirwayName Previous Next AirwayName Previous Next
03SML 25.61 30.635278 L321 57SML KUNAK W8 AST KHG
00MKK 22.52805 -156.1709 R464 BITTA CKH99 blank blank blank
For every airway the same waypoint has, I need a new column with the previous and next fields next to it. Each waypoint may have several airways associated with it(usually not more than 10). The order in which the previous and next entries appear is not especially important.
From what I've gathered, if this is even possible, this kind of operation can be done using multiple crosstab queries.
Any help is appreciated. Thank you.

I reckon you need VBA. You can create a recordset ordered by Waypoint and just keep adding to a delimited string until the next waypoint. This way, you will end up with something that can be saved as a CSV. Alternatively, if it is a once off and there are not too many rows, you might consider importing the whole lot into Excel and doing the work there.

Related

Issue when importing dataset: Rows that contain more elements/columns than the previous row are divided between two rows

For a project I receive datasets in the form of text files. These text files are generated by the measuring software from a machine. The data in the files is seperated by spaces and has no header, example of a row:
Mo 27.06.2022 12:01:11 MP2 mv:(mean. 5s): 4,824 mg/mü org.C
When loading this data using
my_data <- read.table("File.txt", header = FALSE, sep = "", dec = ",", fill=TRUE, na.strings=c("","NA"))
I obtain 9 columns in the following format (example), as intended.
|Mo|27.06.2022|12:01:11|MP2|mv:(mean.| 5s):| 4,824| mg/mü| org.C|
However, sometimes the data set starts with a notification from the machine (example):
Mo 27.06.2022 11:42:04 {SE14} service requestend
When this happens, the 'regular' 9 column rows are seperated between two rows (example):
Row 1: Mo|27.06.2022|11:58:26|MP1|mv:(mean.| 5s):|
Row 2: 7,858| mg/mü |org.C
How do I tell R to not perform this seperation between two rows? As I understand, it does this because earlier in the text file, an input of only 6 columns is recognized.
This is a script that we will use for years to come, so help is greatly appreciated!
I've tried removing the fill function from the read.table function, I have tried removing the na.strings, and ofcourse looking for answers on stack overflow, but was not able to encounter this specific problem.

Change order of categorical bars in Plotly parallel categories

I am trying to visualize changes in gene expression as categorical variables (up, down, no change) over various timepoints.
I have a dataframe describing differential expression data that looks like this:
data = {'gene':['Svm3G0018840','Svm5G0011050','Svm9G0059770'],
'01h': ['nc','up','down'], '04h': ['up', 'down', 'nc'],'08h':['nc','down','up']}
df=pd.DataFrame.from_dict(data)
df=df.set_index('gene')
I can use this df to create the parallel plot using the following code:
fig = px.parallel_categories(herbdf, dimensions=['01h', '04h', '08h','24h','48h'],
labels={'01h':'', '04h':'', '08h':'','24h':'','48h':''})
fig.show()
However, the categories (up, down, nc) are not always in the same order for every time point which makes the figure very difficult to read. I can change this in the interactive figure in a notebook, but I only have the option to output the corrected figure as a low quality png. I need the image in an svg format, which means I need to use the line:
fig.write_image("/figs/herb_de_pp.svg")
But when I add this line in the code block to save the figure I have no control of the order the categorical boxes end up in:
I have tried to add fig.update_ lines to solve this problem, such as:
fig.update_layout(xaxis={'categoryorder':'total descending'})
but this doesn't seem to change the output at all.
I could be missing something simple- any help would be much appreciated!
Parallel coordinates diagrams don't have xaxis/yaxis properties, you need to update traces in order to change the dimensions order:
dimensions = ['01h', '04h', '08h','24h','48h']
...
fig.update_traces(dimensions=[{"categoryorder": "category descending"} for _ in dimensions])
not great answer here, but something that I think will work in a pinch...
It looks like the order of the categories of each figure/column come from the order that they are in the original dataset. That is, in your first column, nc is the first unique item, then down is the second unique item, up is third.
So, if you can rearrange/sort your data so that the data shows up in the order you want it displayed, that should work.
Have your first row be nc | nc | nc | nc | nc, second row down | down | down | down | down, and third row up | up | up | up | up (assuming you actually have records like that). That should do it, but isn't very elegant...
Given the above solution, this is the line needed to sort the dataframe and produce the figure with ordered categories:
sorteddf = df.sort_values(by=['01h','04h','08h'], axis=0, ascending=False)

NAT3176 Error in call to Adabas subroutine or in inverted list

I am having trouble figuring out how to fix this error in Natural Adabas. I am just starting out with Natural on a very old version and the problem I keep running into trying to run most of the existing programs written by previous developers is that I keep getting this error.
NAT3176 Error in call to Adabas subroutine or in inverted list.
So I have attempted a very basic program of my own with the same result (see below). Does anybody know how to resolve this problem or what steps can be taken to debug?
My first thought is that the STUD list does not exist even though there is a DDM for it. Is there a way I could verify that it exists?
My test program is as follows:
0010 DEFINE DATA
0020 LOCAL
0030 1 STUD-VIEW VIEW OF STUD
0040 2 STUDNO
0050 END-DEFINE
0060 READ STUD-VIEW BY STUDNO
0070 DISPLAY STUDNO
0080 END-READ
0090 END
NAT3176: Inconsistency detected in an inverted list.
That's what the docs say, so very likely the Index ("inverted list") is corrupt.
You'll certainly need your Admin to fix that.
Try omitting the BY STUDNO from the READ Statement.
It will then perform a READ PHYSICAL ("Full Table Scan" in a relational DB) which accesses the data without using the index.
That would look something like this:
DEFINE DATA
LOCAL 1 STUD-VIEW VIEW OF STUD
2 STUDNO
END-DEFINE
*
READ STUD-VIEW
DISPLAY STUDNO
END-READ
END

SQL Server 2005 Parse text into columns

I have text in columns that I want to parse out to multiple columns. The text is separated by \
Example 1 column:
alarmname
Rainier Beach (Henderson)\Tunnel Facility\C29_Facility\Offline - PLC 70
Rainier Beach (Henderson)\Tunnel Facility\C30_Facility\PLC DC Power 3 - Fault
I want to parse them into separate columns for each record. For example, for the first record above it would look like:
Rainier Beach (Henderson)
Tunnel Facility
C29_Facility
Offline - PLC 70
I can parse the first text value by using:
LEFT(alarmname,charindex('\',alarmname)-1)
which gives me:
Rainier Beach (Henderson)
But I don't know how to parse the second, third, fourth values...
Try this link... it has a great Function you can use. All you need to do is add the function and then you call split('/', fieldname) and it works like a charm.
http://www.webtechminer.com/split-function-in-sql-server-to-break-comma-separated-string/
It returns a table.

How to access data NOAA data through GRADS?

I'm trying to get some DAP data from noaa, but can't figure out how to pass variables to it. I've looked and looked and haven't found how to just poke around at it with my browser. The data is located at http://nomads.ncep.noaa.gov:9090/dods/ruc/ruc20110725/ruc_f17.info (which may become outdated some time after this post sits around.)
I want to access the ugrd10m variable with the variables time, latitude, and longitude. Any ideas what url is needed to do this?
According to their documentation, it sounds like you want to point your browser at a URL like:
http://nomads.ncep.noaa.gov:9090/dods/ruc/ruc20110914/ruc_f17.ascii?ugrd10m[0:1][0:1][0:1]
That will return a table of the ugrd10m values for the first two time/lat/lon points:
ugrd10m, [2][2][2]
[0][0], 9.999E20, 9.999E20
[0][1], 9.999E20, 9.999E20
[1][0], 9.999E20, 9.999E20
[1][1], 9.999E20, 9.999E20
time, [2]
734395.0, 734395.0416666666
lat, [2]
16.281, 16.46570909091
lon, [2]
-139.856603, -139.66417731424
The number of time/lat/lon points is given under the long description of ugrd10m at the dataset info address:
http://nomads.ncep.noaa.gov:9090/dods/ruc/ruc20110914/ruc_f17.info
time: Array of 64 bit Reals [time = 0..18]
means that there are 19 different time values, at indexes 0 to 18. In this case, the complete dataset can be retrieved by setting all the ranges to the max values:
http://nomads.ncep.noaa.gov:9090/dods/ruc/ruc20110914/ruc_f17.ascii?ugrd10m[0:18][0:226][0:427]
According to this reference, you can access data with this URL:
http://nomads.ncep.noaa.gov:9090/dods/ruc/ruc20110914/ruc_00z.asc?ugrd10m&time=19&time=227&time=428
However, I can't confirm the data's validity.